Improve app startup time measurement
Bug: 171016031
Test: ./time_to_init_disp.sh
Change-Id: I8290b86a5edc55812f7f24a86d50db75a268237e
diff --git a/performance/time_to_init_disp.sh b/performance/time_to_init_disp.sh
index 7e4d98f..2438853 100755
--- a/performance/time_to_init_disp.sh
+++ b/performance/time_to_init_disp.sh
@@ -20,12 +20,22 @@
e.g.
PKG_NAME="com.android.car.dialer" \
ACT_NAME=".ui.TelecomActivity" \
- LOOPS=10 \
+ LOOPS=3 \
+ SLEEP_SEC=3 \
./time_to_init_disp.sh
+
+Notes:
+ - This will not work on User builds.
'
exit
}
+stop_pkg() {
+ echo "Force-stop $PKG_NAME"
+ adb shell am force-stop "$PKG_NAME"
+ sleep $SLEEP_SEC
+}
+
if [[ -z $PKG_NAME ]]; then
PKG_NAME="com.android.car.media"
fi
@@ -36,25 +46,31 @@
ACTIVITY="$PKG_NAME/$ACT_NAME"
if [[ -z $LOOPS ]]; then
- LOOPS=10
+ LOOPS=3
fi
+
+if [[ -z $SLEEP_SEC ]]; then
+ SLEEP_SEC=3
+fi
+
echo "Time $ACTIVITY to Initial Display for $LOOPS times."
+adb shell getprop ro.build.fingerprint
+stop_pkg
+
START=1
-SLEEP_SEC=3
adb root
adb logcat -c
for (( l=$START; l<=$LOOPS; l++ )); do
- echo "Force-stop $PKG_NAME"
- adb shell am force-stop "$PKG_NAME"
- sleep $SLEEP_SEC
-
echo "Dropping caches"
adb shell "echo 3 > /proc/sys/vm/drop_caches"
echo "Loop: $l"
- adb shell am start -n "$ACTIVITY"
+ # -S: Force stop the target app before starting the activity.
+ # -W: Wait for launch to complete.
+ adb shell am start -S -W -n "$ACTIVITY"
sleep $SLEEP_SEC
+ stop_pkg
done
echo