• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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#
7iterations=10
8startapps=1
9capturesystrace=0
10waittime=4
11app=chrome
12
13function 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
37CMDDIR=$(dirname $0 2>/dev/null)
38CMDDIR=${CMDDIR:=.}
39. $CMDDIR/defs.sh
40
41case $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(ariel)
67	flingtime=200
68	downCount=5
69	upCount=5
70	UP="500 1560 500 530 $flingtime"
71	DOWN="500 530 500 1560 $flingtime";;
72(*)
73	echo "Error: No display information available for $DEVICE"
74	exit 1;;
75esac
76
77function swipe {
78	count=0
79	while [ $count -lt $2 ]
80	do
81		doSwipe $1
82		((count=count+1))
83	done
84	sleep 1
85}
86
87cur=1
88frameSum=0
89jankSum=0
90latency90Sum=0
91latency95Sum=0
92latency99Sum=0
93
94doKeyevent HOME
95sleep 0.5
96resetJankyFrames $(getPackageName $app)
97
98while [ $cur -le $iterations ]
99do
100	if [ $capturesystrace -gt 0 ]; then
101		${ADB}atrace --async_start -z -c -b 16000 freq gfx view idle sched
102	fi
103	t=$(startActivity $app)
104	sleep $waittime
105	swipe "$UP" $upCount
106
107	sleep $waittime
108	swipe "$DOWN" $downCount
109
110	doKeyevent BACK
111	sleep 0.5
112
113	if [ $capturesystrace -gt 0 ]; then
114		${ADB}atrace --async_dump -z -c -b 16000 freq gfx view idle sched > trace.${cur}.out
115	fi
116	doKeyevent HOME
117	sleep 0.5
118
119	set -- $(getJankyFrames $(getPackageName $app))
120	totalDiff=$1
121	jankyDiff=$2
122	latency90=$3
123	latency95=$4
124	latency99=$5
125	if [ ${totalDiff:=0} -eq 0 ]; then
126		echo Error: could not read frame info with \"dumpsys gfxinfo\"
127		exit 1
128	fi
129
130	((frameSum=frameSum+totalDiff))
131	((jankSum=jankSum+jankyDiff))
132	((latency90Sum=latency90Sum+latency90))
133	((latency95Sum=latency95Sum+latency95))
134	((latency99Sum=latency99Sum+latency99))
135	if [ "$totalDiff" -eq 0 ]; then
136		echo Error: no frames detected. Is the display off?
137		exit 1
138	fi
139	((jankPct=jankyDiff*100/totalDiff))
140	resetJankyFrames $(getPackageName $app)
141
142
143	echo Frames: $totalDiff latency: $latency90/$latency95/$latency99 Janks: $jankyDiff\(${jankPct}%\)
144	((cur=cur+1))
145done
146doKeyevent HOME
147((aveJankPct=jankSum*100/frameSum))
148((aveJanks=jankSum/iterations))
149((aveFrames=frameSum/iterations))
150((aveLatency90=latency90Sum/iterations))
151((aveLatency95=latency95Sum/iterations))
152((aveLatency99=latency99Sum/iterations))
153echo AVE: Frames: $aveFrames latency: $aveLatency90/$aveLatency95/$aveLatency99 Janks: $aveJanks\(${aveJankPct}%\)
154