I'm trying to automatically collect performance data (loading and screen rendering times) from an Android app. I use test-runner.py
(an internal tool) to build the app and run the tests before using the adb
command to get the performance data. My bash script looks like this:
BASE_DIR=../Application/app/src/custom-feeds
CTF_DIR=../../../../ComponentTestFramework
OUTPUT_FILE=out.txt
if test -e $OUTPUT_FILE
then
rm $OUTPUT_FILE
fi
teardown ()
{
cd $BASE_DIR
adb logcat -d PerformanceTest:D *:S | grep 'Loading' | tee -a $OUTPUT_FILE
adb logcat -d ActivityManager:I *:S | grep 'ContentBrowseActivity:\s+\+' | tee -a $OUTPUT_FILE
./restore.sh
}
# small sample feed
echo Testing sample feed with 10 initial items
echo size = 10 > $OUTPUT_FILE
cd $CTF_DIR
python3 test_runner.py -f $BASE_DIR/config-B-10.json
teardown
# medium sample feed
echo Testing sample feed with 100 initial items
echo size = 100 > $OUTPUT_FILE
cd $CTF_DIR
python3 test_runner.py -f $BASE_DIR/config-B-100.json
teardown
# large sample feed
echo Testing sample feed with 500 initial items
echo size = 500 > $OUTPUT_FILE
cd $CTF_DIR
python3 test_runner.py -f $BASE_DIR/config-B-500.json
teardown
# super large sample feed
echo Testing sample feed with 5000 initial items
echo size = 5000 > $OUTPUT_FILE
cd $CTF_DIR
python3 test_runner.py -f $BASE_DIR/config-B-5000.json
teardown
When the script is first run, the data gets written to the output file as expected:
size = 100
However, nothing else gets written until the script finishes executing. The output file now looks like this:
size = 5000
D/PerformanceTest( 1458): Loading time: 332874 ms
I/ActivityManager( 1843): Displayed com.amazon.android.calypso/com.amazon.android.tv.tenfoot.ui.activities.ContentBrowseActivity: +563ms
There are two issues:
-a
switch in tee
.What am I doing wrong?
Answering my own question in embarrassment.
The issue was due to my use of >
(which overwrites the file) than >>
(which appends to it). Using >>
obviously solved the problem. I'm still facepalming as I type this.