#!/bin/sh # Scrolls the transcript and prints the app's own render report -- the # standard measurement for "is the transcript smooth", so a perf session # starts from a number instead of re-inventing this loop in /tmp. # # ./transcript-bench.sh restart the app, open the session the # server lists first, scroll, report # ./transcript-bench.sh -s TITLE open that session instead # ./transcript-bench.sh -k keep whatever screen is open now # ./transcript-bench.sh -n 4 swipe cycles (default 6; one cycle is # two swipes back and two forward) # # What it prints is the report the in-app copy button produces, plus any # duplicate-key warnings the flatten logged. Absolute frame times from the # emulator are worthless (it renders in software); what transfers is the # report's own accounting -- what was on screen, and where the draw phase # went. Compare two runs of this with the same gestures, not one run # against a phone. # # The swipes are still coordinates, because a gesture across a scrolling # area is a distance rather than a control. Every *control* is pressed by # name -- see bench-lib.sh. set -eu cd "$(dirname "$0")" . ./android-env.sh >/dev/null 2>&1 . ./bench-lib.sh keep="" cycles=6 session="" while getopts kn:s: flag; do case $flag in k) keep=1 ;; n) cycles=$OPTARG ;; s) session=$OPTARG ;; *) exit 2 ;; esac done if [ -z "$keep" ]; then [ -n "$session" ] || session=$(first_session_title) [ -n "$session" ] || { echo "transcript-bench: no sessions to open" >&2; exit 1; } open_session "$session" fi # The first copy resets the report's "work since last copied" window, so the # numbers cover exactly the swipes between the two. copy_render_report /tmp/bench-reset.txt adb logcat -c DO="" i=0 while [ "$i" -lt "$cycles" ]; do DO="$DO --do 'swipe 540 700 540 1600 200' --do 'wait 500'" DO="$DO --do 'swipe 540 700 540 1600 200' --do 'wait 500'" DO="$DO --do 'swipe 540 1600 540 700 200' --do 'wait 500'" DO="$DO --do 'swipe 540 1600 540 700 200' --do 'wait 500'" i=$((i + 1)) done eval ui-trace record -d $((cycles * 4400 + 2000)) $DO -o /tmp/bench-scroll.txt >/dev/null 2>&1 copy_render_report /tmp/bench-report.txt sleep 1 adb logcat -d -s ai-app:I | sed -n '/ai-app render report/,$p' | sed 's/^.*ai-app : //' adb logcat -d 2>/dev/null | grep -i "duplicate unit key" | head -3 || true