OSDN Git Service

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