• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -x
2
3# usage: run-startup.sh <package name> <activity name>
4
5# Runs an Android app, collects a trace and prints out a summary of startup
6# metrics.
7
8PACKAGE=$1
9ACTIVITY=$2
10
11ADB=adb
12
13# Make sure we use the right adb, etc.
14$ADB root
15
16# Stop the app
17$ADB shell "am force-stop $PACKAGE"
18
19# Make sure it's compiled for speed
20$ADB shell "pm compile -m speed $PACKAGE"
21
22# Clear the page cache
23$ADB shell "echo 3 > /proc/sys/vm/drop_caches"
24
25# Start tracing
26$ADB shell "atrace -a $PACKAGE -b 32768 --async_start input dalvik view am wm sched freq idle sync irq binder_driver workq hal freq"
27
28# Launch the app
29$ADB shell "am start -W -n $PACKAGE/$ACTIVITY"
30
31# Wait a little longer for the app to do whatever it does.
32sleep 10
33
34# Capture the trace
35$ADB shell "atrace --async_stop -o /sdcard/atrace.trace"
36
37# Get the trace
38$ADB pull /sdcard/atrace.trace
39
40# Dump the startup info
41./gradlew :trebuchet:startup-analyzer:run --args="`pwd`/atrace.trace"
42