aosp12/tools/trebuchet/scripts/run-startup.sh

42 lines
949 B
Bash
Raw Permalink Normal View History

2023-01-09 17:11:35 +08:00
#!/bin/bash -x
# usage: run-startup.sh <package name> <activity name>
# Runs an Android app, collects a trace and prints out a summary of startup
# metrics.
PACKAGE=$1
ACTIVITY=$2
ADB=adb
# Make sure we use the right adb, etc.
$ADB root
# Stop the app
$ADB shell "am force-stop $PACKAGE"
# Make sure it's compiled for speed
$ADB shell "pm compile -m speed $PACKAGE"
# Clear the page cache
$ADB shell "echo 3 > /proc/sys/vm/drop_caches"
# Start tracing
$ADB shell "atrace -a $PACKAGE -b 32768 --async_start input dalvik view am wm sched freq idle sync irq binder_driver workq hal freq"
# Launch the app
$ADB shell "am start -W -n $PACKAGE/$ACTIVITY"
# Wait a little longer for the app to do whatever it does.
sleep 10
# Capture the trace
$ADB shell "atrace --async_stop -o /sdcard/atrace.trace"
# Get the trace
$ADB pull /sdcard/atrace.trace
# Dump the startup info
./gradlew :trebuchet:startup-analyzer:run --args="`pwd`/atrace.trace"