import sys, zlib
def main():
-
- if len(sys.argv) != 2:
- print >> sys.stderr, ('Usage: %s inputfile' % sys.argv[0])
- sys.exit(1)
+
+ if len(sys.argv) != 2:
+ print >> sys.stderr, ('Usage: %s inputfile' % sys.argv[0])
+ sys.exit(1)
- infile = open(sys.argv[1], "rb")
- out = infile.read()
- parts = out.split('\nTRACE:', 1)
+ infile = open(sys.argv[1], "rb")
+ out = infile.read()
+ parts = out.split('\nTRACE:', 1)
- data = ''.join(parts[1])
+ data = ''.join(parts[1])
- # Remove CR characters
- if data.startswith('\r\n'):
- data = data.replace('\r\n', '\n')
+ # Remove CR characters
+ if data.startswith('\r\n'):
+ data = data.replace('\r\n', '\n')
- # Skip the initial newline.
- data = data[1:]
+ # Skip the initial newline.
+ data = data[1:]
- if not data:
- print >> sys.stderr, ('No trace data found')
- sys.exit(1)
+ if not data:
+ print >> sys.stderr, ('No trace data found')
+ sys.exit(1)
- out = zlib.decompress(data)
- print(out)
+ out = zlib.decompress(data)
+ print(out)
if __name__ == '__main__':
- main()
+ main()
echo Capturing input for $DEVICE...
stdbuf -o0 adb shell getevent -t |
- stdbuf -o0 grep "event.: 0003" |
+ stdbuf -o0 grep "event.: 0003" |
stdbuf -o0 grep "0003 003[0156a9]" |
stdbuf -o0 tr ':[]\r' ' ' | while read line
do
case $code in
(0035) x=$(convert $value $xmax $xscale);;
(0036) y=$(convert $value $ymax $yscale);;
- (0030) tag="majorTouch";;
+ (0030) tag="majorTouch";;
(0031) tag="minorTouch";;
(003a) tag="pressure";;
(0039) tag="trackingId";;
gmailActivity='com.google.android.gm/com.google.android.gm.ConversationListActivityGmail'
hangoutsActivity='com.google.android.talk/com.google.android.talk.SigningInActivity'
chromeActivity='com.android.chrome/com.google.android.apps.chrome.ChromeTabbedActivity'
+chromeLActivity='com.android.chrome/com.google.android.apps.chrome.document.DocumentActivity'
youtubeActivity='com.google.android.youtube/com.google.android.apps.youtube.app.WatchWhileActivity'
cameraActivity='com.google.android.GoogleCamera/com.android.camera.CameraActivity'
playActivity='com.android.vending/com.google.android.finsky.activities.MainActivity'
log2msec $(findtimestamp $f)
}
+function resetJankyFrames {
+ ${ADB}dumpsys gfxinfo $1 reset 2>&1 >/dev/null
+}
+
function getJankyFrames {
if [ -z "$ADB" ]; then
# Note: no awk or sed on devices so have to do this
cat ./janky.$$
rm -f ./janky.$$
else
- ${ADB}dumpsys gfxinfo | sed -e 's/\r//' | awk '
+ ${ADB}dumpsys gfxinfo $1 | sed -e 's/\r//' | awk '
BEGIN { total=0; janky=0; }
/Total frames/ { total+=$4; }
/Janky frames/ { janky+=$3; }
return 0
fi
vout $AM_START_NOWAIT -p "$(getPackageName $1)" -c android.intent.category.LAUNCHER -a android.intent.action.MAIN
- $AM_START_NOWAIT -p "$(getPackageName $1)" -c android.intent.category.LAUNCHER -a android.intent.action.MAIN 2>&1
+ $AM_START_NOWAIT -p "$(getPackageName $1)" -c android.intent.category.LAUNCHER -a android.intent.action.MAIN 2>&1
echo 0
}
doKeyevent HOME
echo 0
return 0
+ elif [ "$1" = chromeL ]; then
+ vout $AM_START -p "$(getPackageName $1)" http://www.theverge.com
+ set -- $($AM_START -p "$(getPackageName $1)" http://www.theverge.com | grep ThisTime)
+ else
+ vout $AM_START "$(getActivityName $1)"
+ set -- $($AM_START "$(getActivityName $1)" | grep ThisTime)
fi
- vout $AM_START "$(getActivityName $1)"
- set -- $($AM_START "$(getActivityName $1)" | grep ThisTime)
echo $2 | tr "[\r]" "[\n]"
}
function forceStartActivity {
- vout $AM_FORCE_START "$(getActivityName $1)"
- set -- $($AM_FORCE_START "$(getActivityName $1)" | grep ThisTime)
+ if [ "$1" = chromeL ]; then
+ # force start doesn't work for chrome (hangs on startup)
+ startActivity $*
+ return 0
+ else
+ vout $AM_FORCE_START "$(getActivityName $1)"
+ set -- $($AM_FORCE_START "$(getActivityName $1)" | grep ThisTime)
+ fi
echo $2 | tr "[\r]" "[\n]"
}
t=$2
restart=$3
reclaim=$4
+ frames=$5
+ janks=$6
curMax=$(eval "echo \$${label}max")
curMax=${curMax:=0}
curMin=$(eval "echo \$${label}min")
curRestart=${curRestart:=0}
curReclaim=$(eval "echo \$${label}reclaim")
curReclaim=${curReclaim:=0}
+ curFrames=$(eval "echo \$${label}frames")
+ curFrames=${curFrames:=0}
+ curJanks=$(eval "echo \$${label}janks")
+ curJanks=${curJanks:=0}
if [ $curMax -lt $t ]; then
eval "${label}max=$t"
fi
eval "${label}restart=$curRestart"
((curReclaim=curReclaim+${reclaim:=0}))
eval "${label}reclaim=$curReclaim"
+ ((curFrames=curFrames+${frames:=0}))
+ eval "${label}frames=$curFrames"
+ ((curJanks=curJanks+${janks:=0}))
+ eval "${label}janks=$curJanks"
}
function getStats {
label=$1
echo $(eval "echo \$${label}max") $(eval "echo \$${label}min") $(eval "echo \$${label}sum") \
- $(eval "echo \$${label}restart") $(eval "echo \$${label}reclaim")
+ $(eval "echo \$${label}restart") $(eval "echo \$${label}reclaim") \
+ $(eval "echo \$${label}frames") $(eval "echo \$${label}janks")
}
cur=1
fi
if [ $iterations -gt 1 -o $cur -eq 1 ]; then
if [ $totaltimetest -eq 0 ]; then
- printf "%-6s %7s(ms) %6s(ms) %s %s %s\n" App Time AmTime Restart DirReclaim
+ printf "%-6s %7s(ms) %6s(ms) %s %s %s %s\n" App Time AmTime Restart DirReclaim JankyFrames
fi
fi
tmpTraceOut="$tmpTraceOutBase-$app.out"
>$tmpTraceOut
startInstramentation
+ resetJankyFrames $(getPackageName $app)
t=$(startActivity $app)
+ # let app finish drawing before checking janks
+ sleep 3
+ set -- $(getJankyFrames $(getPackageName $app))
+ frames=$1
+ janks=$2
+ ((jankPct=100*janks/frames))
stopAndDumpInstramentation $tmpTraceOut
actName=$(getActivityName $app)
stime=$(getStartTime $actName $tmpTraceOut)
checkForDirectReclaim $actName $tmpTraceOut
directReclaim=$?
- printf "%-12s %5d %5d %5d %5d\n" "$app" "$tdiff" "$t" "$relaunch" "$directReclaim"
- computeStats "$app" "$tdiff" "$relaunch" "$directReclaim"
+ printf "%-12s %5d %5d %5d %5d %5d(%d%%)\n" "$app" "$tdiff" "$t" "$relaunch" "$directReclaim" "$janks" "$jankPct"
+ computeStats "$app" "$tdiff" "$relaunch" "$directReclaim" "$frames" "$janks"
if [ $savetmpfiles -eq 0 ]; then
rm -f $tmpTraceOut
echo =========================================
printf "Stats after $iterations iterations:\n"
echo =========================================
- printf "%-6s %7s(ms) %6s(ms) %6s(ms) %s %s %s\n" App Max Ave Min Restart DirReclaim
+ printf "%-6s %7s(ms) %6s(ms) %6s(ms) %s %s %s %s\n" App Max Ave Min Restart DirReclaim JankyFrames
for app in $appList
do
set -- $(getStats $app)
sum=$3
((ave=sum/iterations))
- printf "%-12s %5d %5d %5d %5d %5d\n" $app $1 $ave $2 $4 $5
+ frames=$6
+ janks=$7
+ ((jankPct=100*janks/frames))
+ printf "%-12s %5d %5d %5d %5d %5d %5d(%d%%)\n" $app $1 $ave $2 $4 $5 $janks $jankPct
done
fi