OSDN Git Service

Merge "Remove system/extras/tests/bionic." am: 1205856a99
[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 (angler)
48         flingtime=150
49         downCount=4
50         upCount=3
51         UP="500 1200 500 550 $flingtime"
52         DOWN="500 550 500 1200 $flingtime";;
53 (bullhead)
54         flingtime=200
55         downCount=5
56         upCount=5
57         UP="500 1200 500 550 $flingtime"
58         DOWN="500 550 500 1200 $flingtime";;
59 (volantis)
60         flingtime=400
61         downCount=5
62         upCount=6
63         UP="70 400 70 70 $flingtime"
64         DOWN="70 70 70 400 $flingtime";;
65 (*)
66         echo "Error: No display information available for $DEVICE"
67         exit 1;;
68 esac
69
70 doKeyevent HOME
71 if [ $startapps -gt 0 ]; then
72
73         # start a bunch of apps
74         for app in $appList
75         do
76                 echo Starting $app ...
77                 t=$(startActivity $app)
78         done
79 fi
80
81 function swipe {
82         count=0
83         while [ $count -lt $2 ]
84         do
85                 doSwipe $1
86                 ((count=count+1))
87         done
88 }
89
90 cur=1
91 frameSum=0
92 jankSum=0
93 latency90Sum=0
94 latency95Sum=0
95 latency99Sum=0
96
97 echo Fling recents...
98 doKeyevent HOME
99 sleep 0.5
100 resetJankyFrames
101
102 while [ $cur -le $iterations ]
103 do
104         if [ $capturesystrace -gt 0 ]; then
105                 ${ADB}atrace --async_start -z -c -b 16000 freq gfx view idle sched
106         fi
107         doKeyevent APP_SWITCH
108         sleep 0.5
109         swipe "$DOWN" $downCount
110         sleep 1
111         swipe "$UP" $upCount
112         sleep 1
113         swipe "$DOWN" $downCount
114         sleep 1
115         swipe "$UP" $upCount
116         sleep 1
117         if [ $capturesystrace -gt 0 ]; then
118                 ${ADB}atrace --async_dump -z -c -b 16000 freq gfx view idle sched > trace.${cur}.out
119         fi
120         doKeyevent HOME
121         sleep 0.5
122
123         set -- $(getJankyFrames)
124         totalDiff=$1
125         jankyDiff=$2
126         latency90=$3
127         latency95=$4
128         latency99=$5
129         if [ ${totalDiff:=0} -eq 0 ]; then
130                 echo Error: could not read frame info with \"dumpsys gfxinfo\"
131         fi
132
133         ((frameSum=frameSum+totalDiff))
134         ((jankSum=jankSum+jankyDiff))
135         ((latency90Sum=latency90Sum+latency90))
136         ((latency95Sum=latency95Sum+latency95))
137         ((latency99Sum=latency99Sum+latency99))
138         if [ "$totalDiff" -eq 0 ]; then
139                 echo Error: no frames detected. Is the display off?
140         fi
141         ((jankPct=jankyDiff*100/totalDiff))
142         resetJankyFrames
143
144         echo Frames: $totalDiff latency: $latency90/$latency95/$latency99 Janks: $jankyDiff\(${jankPct}%\)
145         ((cur=cur+1))
146 done
147 doKeyevent HOME
148 ((aveJankPct=jankSum*100/frameSum))
149 ((aveJanks=jankSum/iterations))
150 ((aveFrames=frameSum/iterations))
151 ((aveLatency90=latency90Sum/iterations))
152 ((aveLatency95=latency95Sum/iterations))
153 ((aveLatency99=latency99Sum/iterations))
154 echo AVE: Frames: $aveFrames latency: $aveLatency90/$aveLatency95/$aveLatency99 Janks: $aveJanks\(${aveJankPct}%\)