Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: platform_tools/android/bin/android_perf

Issue 22617002: Update Skia Android tools. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 # 2 #
3 # android_perf: utility for running perf on an android device 3 # android_perf: utility for running perf on an android device
4 # 4 #
5 # The basic usage sequence is to run... 5 # The basic usage sequence is to run...
6 # 1) perf record [gm/tests/bench] # runs profiler on specified app 6 # 1) perf record [gm/tests/bench] # runs profiler on specified app
7 # 2) perf report # prints profiler results 7 # 2) perf report # prints profiler results
8 # 3) perf clean # cleans the temporary directory used to store results 8 # 3) perf clean # cleans the temporary directory used to store results
9 # 9 #
10 10
11 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 11 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
12 PERF_CMD=$1 12 source $SCRIPT_DIR/android_setup.sh
13
14 source $SCRIPT_DIR/utils/setup_adb.sh 13 source $SCRIPT_DIR/utils/setup_adb.sh
15 14
16 if [ $(uname) == "Linux" ]; then 15 if [ $(uname) == "Linux" ]; then
17 PERFHOST=$SCRIPT_DIR/linux/perfhost 16 PERFHOST=$SCRIPT_DIR/linux/perfhost
18 elif [ $(uname) == "Darwin" ]; then 17 elif [ $(uname) == "Darwin" ]; then
19 PERFHOST=$SCRIPT_DIR/mac/perfhost 18 PERFHOST=$SCRIPT_DIR/mac/perfhost
20 else 19 else
21 echo "Could not automatically determine OS!" 20 echo "Could not automatically determine OS!"
22 exit 1; 21 exit 1;
23 fi 22 fi
24 23
24 # grab and remove the perf command from the input args
25 PERF_CMD=${APP_ARGS[0]}
26 unset APP_ARGS[0]
27
28 configuration="Debug"
29 serialNumber=""
30
31 for arg in ${APP_ARGS[@]}
32 do
33 if [[ "${arg}" == "-s" ]];
34 then
35 if [[ $# -lt 2 ]];
36 then
37 echo "ERROR: missing serial number"
38 exit 1;
39 fi
40 # TODO this is a bug to have $1 and $2
41 serialNumber="-s $2"
42 shift
43 elif [[ "$1" == "--release" ]];
44 then
45 configuration="Release"
46 else
47 echo "${arg}"
48 runVars=("${runVars[@]}" "${arg}")
49 fi
50
51 shift
52 done
53
25 # We need the debug symbols from these files 54 # We need the debug symbols from these files
26 PERF_TMP_DIR=$(pwd)/android_perf_tmp 55 PERF_TMP_DIR=$(pwd)/android_perf_tmp
27 56
28 TMP_SYS_BIN=$PERF_TMP_DIR/system/bin 57 TMP_SYS_BIN=$PERF_TMP_DIR/system/bin
29 TMP_SYS_LIB=$PERF_TMP_DIR/system/lib 58 TMP_SYS_LIB=$PERF_TMP_DIR/system/lib
30 TMP_APP_LIB=$PERF_TMP_DIR/data/data/com.skia/lib 59 TMP_APP_LOC=$PERF_TMP_DIR/data/local/tmp
31 60
32 perf_setup() { 61 perf_setup() {
33 62
34 mkdir -p $TMP_SYS_BIN 63 mkdir -p $TMP_SYS_BIN
35 mkdir -p $TMP_SYS_LIB 64 mkdir -p $TMP_SYS_LIB
36 mkdir -p $TMP_APP_LIB 65 mkdir -p $TMP_APP_LOC
37 66
38 # setup symlinks to account for perf potentially looking elsewhere
39 mkdir -p $PERF_TMP_DIR/data/app-lib
40 $( cd $PERF_TMP_DIR/data/app-lib && ln -s ../data/com.skia/lib com.skia-1)
41 $( cd $PERF_TMP_DIR/data/app-lib && ln -s ../data/com.skia/lib com.skia-2)
42
43 echo "Copying symbol files" 67 echo "Copying symbol files"
44 $ADB pull /system/bin/skia_launcher $TMP_SYS_BIN 68 adb_pull_if_needed /system/lib/libc.so $TMP_SYS_LIB
45 $ADB pull /system/lib/libc.so $TMP_SYS_LIB 69 adb_pull_if_needed /system/lib/libstlport.so $TMP_SYS_LIB
46 $ADB pull /system/lib/libstlport.so $TMP_SYS_LIB 70 adb_pull_if_needed /system/lib/libcutils.so $TMP_SYS_LIB
47 $ADB pull /system/lib/libcutils.so $TMP_SYS_LIB 71 adb_pull_if_needed /system/lib/libGLESv2.so $TMP_SYS_LIB
48 $ADB pull /system/lib/libGLESv2.so $TMP_SYS_LIB 72 adb_pull_if_needed /system/lib/libandroid.so $TMP_SYS_LIB
49 $ADB pull /system/lib/libandroid.so $TMP_SYS_LIB 73 adb_pull_if_needed /system/lib/libm.so $TMP_SYS_LIB
50 $ADB pull /system/lib/libm.so $TMP_SYS_LIB 74 adb_pull_if_needed /system/lib/libz.so $TMP_SYS_LIB
51 $ADB pull /system/lib/libz.so $TMP_SYS_LIB 75
52 76 if [ ! -f "${SKIA_OUT}/${configuration}/lib.target/lib${runVars[0]}.so" ];
53 if [ $# -ge 2 ]
54 then 77 then
55 APP_NAME=$(basename $2) 78 echo "Unable to find the ${runVars[0]} library"
56 $ADB pull /data/data/com.skia/lib/lib${APP_NAME}.so $TMP_APP_LIB 79 exit 1
57 else
58 $ADB pull /data/data/com.skia/lib/ $TMP_APP_LIB
59 fi 80 fi
60
61 81
82 echo "Pushing app..."
83 adb_push_if_needed "${SKIA_OUT}/${configuration}/skia_launcher" /data/local/ tmp
84 adb_push_if_needed "${SKIA_OUT}/${configuration}/lib.target/libskia_android. so" /data/local/tmp
85 adb_push_if_needed "${SKIA_OUT}/${configuration}/lib.target/lib${runVars[0]} .so" /data/local/tmp
86
87 cp "${SKIA_OUT}/${configuration}/skia_launcher" $TMP_APP_LOC
88 cp "${SKIA_OUT}/${configuration}/lib.target/libskia_android.so" $TMP_APP_LOC
89 cp "${SKIA_OUT}/${configuration}/lib.target/lib${runVars[0]}.so" $TMP_APP_LO C
62 } 90 }
63 91
64 perf_record() { 92 perf_record() {
65 93
66 APP_NAME=$(basename $2)
67 # Collect extra arguments to be passed to the skia_launcher binary
68 shift # perf_cmd
69 shift # app_name
70 while (( "$#" )); do
71 APP_ARGS="$APP_ARGS $1"
72 shift
73 done
74
75 echo "Checking for skia_launcher app..."
76 if [ ! -f $TMP_SYS_BIN/skia_launcher ]
77 then
78 echo "Unable to find the skia_launcher on the device"
79 rm -rf $PERF_TMP_DIR
80 exit 1;
81 fi
82
83 echo "Checking for $APP_NAME library..."
84 if [ ! -f $TMP_APP_LIB/lib$APP_NAME.so ]
85 then
86 echo "Unable to find the app's shared library on the device"
87 rm -rf $PERF_TMP_DIR
88 exit 1;
89 fi
90
91 echo "Killing any running Skia processes." 94 echo "Killing any running Skia processes."
92 $ADB shell ps | grep skia_launcher | awk '{print $2}' | xargs $ADB shell kil l 95 $ADB shell ps | grep skia_launcher | awk '{print $2}' | xargs $ADB shell kil l
93 96
94 echo "Starting application" 97 echo "Starting application"
95 $ADB shell skia_launcher $APP_NAME $APP_ARGS & 98 $ADB shell /data/local/tmp/skia_launcher ${runVars[@]} &
96 99
97 # WE REALLY REALLY WANT TO BE ABLE TO PASS THE SKIA_LAUNCHER APP DIRECTLY TO 100 # WE REALLY REALLY WANT TO BE ABLE TO PASS THE SKIA_LAUNCHER APP DIRECTLY TO
98 # PERF, BUT AT THIS POINT THE DATA FILE WE GET WHEN GOING THAT ROUTE IS UNAB LE 101 # PERF, BUT AT THIS POINT THE DATA FILE WE GET WHEN GOING THAT ROUTE IS UNAB LE
99 # TO BE READ BY THE REPORTING TOOL 102 # TO BE READ BY THE REPORTING TOOL
100 echo "Starting profiler" 103 echo "Starting profiler"
101 APP_PID=$($ADB shell ps | grep skia_launcher | awk '{print $2}') 104 APP_PID=$($ADB shell ps | grep skia_launcher | awk '{print $2}')
102 $ADB shell perf record -p ${APP_PID} sleep 70 105 $ADB shell perf record -p ${APP_PID} sleep 70
103 106
104 $ADB pull /data/perf.data $PERF_TMP_DIR/perf.data 107 $ADB pull /data/perf.data $PERF_TMP_DIR/perf.data
105 108
106 exit 0; 109 exit 0;
107 } 110 }
108 111
109 perf_report() { 112 perf_report() {
110 # Collect extra arguments to be passed to the perfhost binary 113 adb_pull_if_needed /data/perf.data $PERF_TMP_DIR/perf.data
111 while (( "$#" )); do 114 $PERFHOST report -i $PERF_TMP_DIR/perf.data --symfs=$PERF_TMP_DIR ${runVars[ @]}
112 APP_ARGS="$APP_ARGS $1"
113 shift
114 done
115
116 $PERFHOST report -i $PERF_TMP_DIR/perf.data --symfs=$PERF_TMP_DIR $APP_ARGS
117 } 115 }
118 116
119 # Clean up 117 # Clean up
120 perf_clean() { 118 perf_clean() {
121 rm -rf $PERF_TMP_DIR 119 rm -rf $PERF_TMP_DIR
122 } 120 }
123 121
124 case $PERF_CMD in 122 case $PERF_CMD in
125 setup) 123 setup)
126 perf_setup $@ 124 perf_setup ${runVars[@]}
127 ;; 125 ;;
128 record) 126 record)
129 perf_setup $@ 127 perf_setup ${runVars[@]}
130 perf_record $@ 128 perf_record ${runVars[@]}
131 ;; 129 ;;
132 report) 130 report)
133 perf_report 131 perf_report
134 ;; 132 ;;
135 clean) 133 clean)
136 perf_clean 134 perf_clean
137 ;; 135 ;;
138 *) 136 *)
139 echo -n "ERROR: unknown perf command ($PERF_CMD), valid values: " 137 echo -n "ERROR: unknown perf command ($PERF_CMD), valid values: "
140 echo "setup, record, report, clean" 138 echo "setup, record, report, clean"
141 exit 1; 139 exit 1;
142 ;; 140 ;;
143 esac 141 esac
144 142
145 exit 0; 143 exit 0;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698