Home | History | Annotate | Download | only in workloads
      1 #
      2 # Script to play a john oliver youtube video N times.
      3 # For each iteration, Total frames and janky frames are reported.
      4 #
      5 # Options are described below.
      6 #
      7 iterations=10
      8 app=youtube
      9 searchText="last week tonight with john oliver: online harassment"
     10 vidMinutes=15
     11 
     12 function processLocalOption {
     13 	ret=0
     14 	case "$1" in
     15 	(-S) searchText="$2"; shift;;
     16 	(-t) vidMinutes="$2"; shift;;
     17 	(*)
     18 		echo "$0: unrecognized option: $1"
     19 		echo; echo "Usage: $0 [options]"
     20 		echo "-i iterations"
     21 		echo "-S youtube search text"
     22 		echo "-d device"
     23 		echo "-t vidMinutes"
     24 		exit 1;;
     25 	esac
     26 	return $ret
     27 }
     28 
     29 CMDDIR=$(dirname $0 2>/dev/null)
     30 CMDDIR=${CMDDIR:=.}
     31 . $CMDDIR/defs.sh
     32 
     33 case $DEVICE in
     34 (angler)
     35 	searchButton="860 177"
     36 	selectFirstVideo="225 400"
     37 	enableControls="1000 610"
     38 	fullScreen="1011 632"
     39 	;;
     40 (shamu)
     41 	searchButton="1200 160"
     42 	selectFirstVideo="480 653"
     43 	enableControls="1377 812"
     44 	fullScreen="1377 812"
     45 	;;
     46 (bullhead|hammerhead)
     47 	searchButton="860 177"
     48 	selectFirstVideo="225 400"
     49 	enableControls="1000 610"
     50 	fullScreen="1011 632"
     51 	;;
     52 (volantis)
     53 	searchButton="1356 93"
     54 	selectFirstVideo="378 264"
     55 	enableControls="1464 812"
     56 	fullScreen="1480 835"
     57 	;;
     58 (ariel)
     59 	searchButton="1440 70"
     60 	selectFirstVideo="228 224"
     61 	enableControls="1528 880"
     62 	fullScreen="1528 880"
     63 	;;
     64 
     65 (*)
     66 	echo "Error: No display information available for $DEVICE"
     67 	exit 1;;
     68 esac
     69 
     70 function swipe {
     71 	count=0
     72 	while [ $count -lt $2 ]
     73 	do
     74 		echo doSwipe...
     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 	t=$(startActivity $app)
     95 	sleep 4.0
     96 	doTap $searchButton
     97 	sleep 1.0
     98 	doText "$searchText"
     99 	sleep 1.0
    100 	doKeyevent ENTER
    101 	sleep 5.0
    102 	doTap $selectFirstVideo
    103 	sleep 10.0
    104 	doTap $fullScreen
    105 	sleep 0.5
    106 	doTap $fullScreen
    107 	# 15 minutes
    108 	((vidTime=60*vidMinutes))
    109 	sleep $vidTime
    110 	doKeyevent BACK
    111 	sleep 0.5
    112 	doKeyevent BACK
    113 	sleep 0.5
    114 	doKeyevent BACK
    115 	sleep 0.5
    116 
    117 	set -- $(getJankyFrames $(getPackageName $app))
    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 	fi
    126 
    127 	((frameSum=frameSum+totalDiff))
    128 	((jankSum=jankSum+jankyDiff))
    129 	((latency90Sum=latency90Sum+latency90))
    130 	((latency95Sum=latency95Sum+latency95))
    131 	((latency99Sum=latency99Sum+latency99))
    132 	if [ "$totalDiff" -eq 0 ]; then
    133 		echo Error: no frames detected. Is the display off?
    134 	fi
    135 	((jankPct=jankyDiff*100/totalDiff))
    136 	resetJankyFrames $(getPackageName $app)
    137 
    138 
    139 	echo Frames: $totalDiff latency: $latency90/$latency95/$latency99 Janks: $jankyDiff\(${jankPct}%\)
    140 	((cur=cur+1))
    141 done
    142 doKeyevent HOME
    143 ((aveJankPct=jankSum*100/frameSum))
    144 ((aveJanks=jankSum/iterations))
    145 ((aveFrames=frameSum/iterations))
    146 ((aveLatency90=latency90Sum/iterations))
    147 ((aveLatency95=latency95Sum/iterations))
    148 ((aveLatency99=latency99Sum/iterations))
    149 echo AVE: Frames: $aveFrames latency: $aveLatency90/$aveLatency95/$aveLatency99 Janks: $aveJanks\(${aveJankPct}%\)
    150