From 8907f4cf961c37a788f01bc93f9c204a2e3b8bc8 Mon Sep 17 00:00:00 2001 From: kalarina Date: Sun, 25 Oct 2026 12:56:53 +0200 Subject: [PATCH] Benchmark: warm the emulator up first and run three rounds by default Two identical APKs differed by 9% in median cold start without it. --- .github/workflows/bench.yml | 4 ++-- scripts/bench.sh | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index d347fb5..6e17eb9 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -10,7 +10,7 @@ on: default: origin/main rounds: description: Rounds per APK (each has 10 cold starts) - default: "2" + default: "3" push: branches: ["bench/**"] @@ -52,7 +52,7 @@ jobs: profile: pixel_6 disable-animations: false emulator-options: -no-snapshot -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - script: bash scripts/bench.sh "$RUNNER_TEMP/bench/base.apk" "$RUNNER_TEMP/bench/head.apk" "${{ inputs.rounds || '2' }}" + script: bash scripts/bench.sh "$RUNNER_TEMP/bench/base.apk" "$RUNNER_TEMP/bench/head.apk" "${{ inputs.rounds || '3' }}" - uses: actions/upload-artifact@v4 if: always() diff --git a/scripts/bench.sh b/scripts/bench.sh index f17c57a..bc284e4 100755 --- a/scripts/bench.sh +++ b/scripts/bench.sh @@ -176,6 +176,16 @@ measure() { echo "::endgroup::" } +# The first launches after boot are far slower than later ones; warm up before measuring +echo "::group::warm-up" +install "$BASE_APK" +for _ in 1 2 3 4 5; do + adb shell am force-stop "$PKG" + launch >/dev/null + sleep 2 +done +echo "::endgroup::" + for r in $(seq "$ROUNDS"); do if (( r % 2 )); then measure base "$BASE_APK"