1# 2# Script to start a set of apps, switch to recents and fling it back and forth. 3# For each iteration, Total frames and janky frames are reported. 4# 5# Options are described below. 6# 7# Works for volantis, shamu, and hammerhead. Can be pushed and executed on 8# the device. 9# 10iterations=10 11startapps=1 12capturesystrace=0 13 14function processLocalOption { 15 ret=0 16 case "$1" in 17 (-N) startapps=0;; 18 (-A) unset appList;; 19 (-L) appList=$2; shift; ret=1;; 20 (-T) capturesystrace=1;; 21 (-B) echo $$ > /dev/cpuset/background/tasks;; 22 (*) 23 echo "$0: unrecognized option: $1" 24 echo; echo "Usage: $0 [options]" 25 echo "-A : use all known applications" 26 echo "-B : run in background cpuset" 27 echo "-L applist : list of applications" 28 echo " default: $appList" 29 echo "-N : no app startups, just fling" 30 echo "-g : generate activity strings" 31 echo "-i iterations" 32 echo "-T : capture systrace on each iteration" 33 exit 1;; 34 esac 35 return $ret 36} 37 38CMDDIR=$(dirname $0 2>/dev/null) 39CMDDIR=${CMDDIR:=.} 40. $CMDDIR/defs.sh 41 42case $DEVICE in 43(shamu|hammerhead) 44 flingtime=300 45 downCount=2 46 upCount=6 47 UP="70 400 70 100 $flingtime" 48 DOWN="70 100 70 400 $flingtime";; 49(angler|ariel|mtp8996) 50 flingtime=150 51 downCount=4 52 upCount=3 53 UP="500 1200 500 550 $flingtime" 54 DOWN="500 550 500 1200 $flingtime";; 55(bullhead) 56 flingtime=200 57 downCount=5 58 upCount=5 59 UP="500 1200 500 550 $flingtime" 60 DOWN="500 550 500 1200 $flingtime";; 61(volantis) 62 flingtime=400 63 downCount=5 64 upCount=6 65 UP="70 400 70 70 $flingtime" 66 DOWN="70 70 70 400 $flingtime";; 67(*) 68 echo "Error: No display information available for $DEVICE" 69 exit 1;; 70esac 71 72doKeyevent HOME 73if [ $startapps -gt 0 ]; then 74 75 # start a bunch of apps 76 for app in $appList 77 do 78 echo Starting $app ... 79 t=$(startActivity $app) 80 done 81fi 82 83function swipe { 84 count=0 85 while [ $count -lt $2 ] 86 do 87 doSwipe $1 88 ((count=count+1)) 89 done 90} 91 92cur=1 93frameSum=0 94jankSum=0 95latency90Sum=0 96latency95Sum=0 97latency99Sum=0 98 99echo Fling recents... 100doKeyevent HOME 101sleep 0.5 102resetJankyFrames 103 104while [ $cur -le $iterations ] 105do 106 if [ $capturesystrace -gt 0 ]; then 107 ${ADB}atrace --async_start -z -c -b 16000 freq gfx view idle sched 108 fi 109 doKeyevent APP_SWITCH 110 sleep 0.5 111 swipe "$DOWN" $downCount 112 sleep 1 113 swipe "$UP" $upCount 114 sleep 1 115 swipe "$DOWN" $downCount 116 sleep 1 117 swipe "$UP" $upCount 118 sleep 1 119 if [ $capturesystrace -gt 0 ]; then 120 ${ADB}atrace --async_dump -z -c -b 16000 freq gfx view idle sched > trace.${cur}.out 121 fi 122 doKeyevent HOME 123 sleep 0.5 124 125 set -- $(getJankyFrames) 126 totalDiff=$1 127 jankyDiff=$2 128 latency90=$3 129 latency95=$4 130 latency99=$5 131 if [ ${totalDiff:=0} -eq 0 ]; then 132 echo Error: could not read frame info with \"dumpsys gfxinfo\" 133 fi 134 135 ((frameSum=frameSum+totalDiff)) 136 ((jankSum=jankSum+jankyDiff)) 137 ((latency90Sum=latency90Sum+latency90)) 138 ((latency95Sum=latency95Sum+latency95)) 139 ((latency99Sum=latency99Sum+latency99)) 140 if [ "$totalDiff" -eq 0 ]; then 141 echo Error: no frames detected. Is the display off? 142 fi 143 ((jankPct=jankyDiff*100/totalDiff)) 144 resetJankyFrames 145 146 echo Frames: $totalDiff latency: $latency90/$latency95/$latency99 Janks: $jankyDiff\(${jankPct}%\) 147 ((cur=cur+1)) 148done 149doKeyevent HOME 150((aveJankPct=jankSum*100/frameSum)) 151((aveJanks=jankSum/iterations)) 152((aveFrames=frameSum/iterations)) 153((aveLatency90=latency90Sum/iterations)) 154((aveLatency95=latency95Sum/iterations)) 155((aveLatency99=latency99Sum/iterations)) 156echo AVE: Frames: $aveFrames latency: $aveLatency90/$aveLatency95/$aveLatency99 Janks: $aveJanks\(${aveJankPct}%\) 157