lin
2025-07-30 fcd736bf35fd93b563e9bbf594f2aa7b62028cc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/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"