OSDN Git Service

Merge "simpleperf: port read_apk and read_apk/read_elf tests to nonlinux."
[android-x86/system-extras.git] / tests / workloads / chromefling.sh
1 #
2 # Script to start 3 chrome tabs, fling each of them, repeat
3 # For each iteration, Total frames and janky frames are reported.
4 #
5 # Options are described below.
6 #
7 iterations=10
8 startapps=1
9 capturesystrace=0
10 waittime=4
11 app=chrome
12
13 function processLocalOption {
14         ret=0
15         case "$1" in
16         (-N) startapps=0;;
17         (-A) unset appList;;
18         (-L) appList=$2; shift; ret=1;;
19         (-T) capturesystrace=1;;
20         (-W) waittime=$2; shift; ret=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                 echo "-d device : device type (shamu, volantis, bullhead,...)"
32                 exit 1;;
33         esac
34         return $ret
35 }
36
37 CMDDIR=$(dirname $0 2>/dev/null)
38 CMDDIR=${CMDDIR:=.}
39 . $CMDDIR/defs.sh
40
41 case $DEVICE in
42 (hammerhead)
43         flingtime=300
44         downCount=2
45         upCount=6
46         UP="70 400 70 100 $flingtime"
47         DOWN="70 100 70 400 $flingtime";;
48 (shamu)
49         flingtime=100
50         downCount=2 
51         upCount=2
52         UP="700 1847 700 400 $flingtime"
53         DOWN="700 400 700 1847 $flingtime";;
54 (angler)
55         flingtime=150
56         downCount=4
57         upCount=3
58         UP="500 1200 500 550 $flingtime"
59         DOWN="500 550 500 1200 $flingtime";;
60 (bullhead|volantis)
61         flingtime=200
62         downCount=5
63         upCount=5
64         UP="500 1400 500 400 $flingtime"
65         DOWN="500 400 500 1400 $flingtime";;
66 (*)
67         echo "Error: No display information available for $DEVICE"
68         exit 1;;
69 esac
70
71 function swipe {
72         count=0
73         while [ $count -lt $2 ]
74         do
75                 doSwipe $1
76                 ((count=count+1))
77         done
78         sleep 1
79 }
80
81 cur=1
82 frameSum=0
83 jankSum=0
84 latency90Sum=0
85 latency95Sum=0
86 latency99Sum=0
87
88 doKeyevent HOME
89 sleep 0.5
90 resetJankyFrames $(getPackageName $app)
91
92 while [ $cur -le $iterations ]
93 do
94         if [ $capturesystrace -gt 0 ]; then
95                 ${ADB}atrace --async_start -z -c -b 16000 freq gfx view idle sched
96         fi
97         t=$(startActivity $app)
98         sleep $waittime
99         swipe "$UP" $upCount
100
101         t=$(startActivity $app)
102         sleep $waittime
103         swipe "$UP" $upCount
104
105         t=$(startActivity $app)
106         sleep $waittime
107         swipe "$UP" $upCount
108
109         doKeyevent BACK
110         sleep $waittime
111         swipe "$DOWN" $downCount
112
113         doKeyevent BACK
114         sleep $waittime
115         swipe "$DOWN" $downCount
116
117         doKeyevent BACK
118         sleep 0.5
119
120         if [ $capturesystrace -gt 0 ]; then
121                 ${ADB}atrace --async_dump -z -c -b 16000 freq gfx view idle sched > trace.${cur}.out
122         fi
123         doKeyevent HOME
124         sleep 0.5
125
126         set -- $(getJankyFrames $(getPackageName $app))
127         totalDiff=$1
128         jankyDiff=$2
129         latency90=$3
130         latency95=$4
131         latency99=$5
132         if [ ${totalDiff:=0} -eq 0 ]; then
133                 echo Error: could not read frame info with \"dumpsys gfxinfo\"
134                 exit 1
135         fi
136
137         ((frameSum=frameSum+totalDiff))
138         ((jankSum=jankSum+jankyDiff))
139         ((latency90Sum=latency90Sum+latency90))
140         ((latency95Sum=latency95Sum+latency95))
141         ((latency99Sum=latency99Sum+latency99))
142         if [ "$totalDiff" -eq 0 ]; then
143                 echo Error: no frames detected. Is the display off?
144                 exit 1
145         fi
146         ((jankPct=jankyDiff*100/totalDiff))
147         resetJankyFrames $(getPackageName $app)
148
149
150         echo Frames: $totalDiff latency: $latency90/$latency95/$latency99 Janks: $jankyDiff\(${jankPct}%\)
151         ((cur=cur+1))
152 done
153 doKeyevent HOME
154 ((aveJankPct=jankSum*100/frameSum))
155 ((aveJanks=jankSum/iterations))
156 ((aveFrames=frameSum/iterations))
157 ((aveLatency90=latency90Sum/iterations))
158 ((aveLatency95=latency95Sum/iterations))
159 ((aveLatency99=latency99Sum/iterations))
160 echo AVE: Frames: $aveFrames latency: $aveLatency90/$aveLatency95/$aveLatency99 Janks: $aveJanks\(${aveJankPct}%\)