diff --git a/quartz/benchmarks/run_all.sh b/quartz/benchmarks/run_all.sh index 322ba22bd..a2228223e 100755 --- a/quartz/benchmarks/run_all.sh +++ b/quartz/benchmarks/run_all.sh @@ -120,24 +120,48 @@ echo "" # ============================================================================ if command -v adb &>/dev/null && adb devices 2>/dev/null | grep -q "device$"; then echo "=== Running Android benchmark (device detected) ===" + # Record start time so we can find results generated by this run. + ANDROID_STAMP="$WORK/.android_stamp" + touch "$ANDROID_STAMP" + "$ROOT/gradlew" -p "$ROOT" :benchmark:connectedBenchmarkAndroidTest \ -Pandroid.testInstrumentationRunnerArguments.class=com.vitorpamplona.quartz.benchmark.Secp256k1Benchmark \ 2>/dev/null || true - # AndroidX Benchmark writes test results XML - ANDROID_XML=$(find "$ROOT/benchmark/build" -path "*test-results*" -name "*.xml" \ - -newer "$ROOT/quartz/benchmarks/run_all.sh" 2>/dev/null | head -1) + FOUND=false + + # 1. Test-results XML (contains benchmark data in CDATA, like JVM results) + ANDROID_XML=$(find "$ROOT/benchmark/build" \ + \( -path "*test-results*" -o -path "*androidTest-results*" \) \ + -name "*.xml" -newer "$ANDROID_STAMP" 2>/dev/null | head -1) if [ -n "$ANDROID_XML" ] && [ -f "$ANDROID_XML" ]; then - cat "$ANDROID_XML" - else - # Try to find results from the sdcard benchmark output + sed -n '//p' "$ANDROID_XML" | grep -v 'CDATA\|]]>' + FOUND=true + fi + + # 2. Pulled benchmark JSON (AndroidX Benchmark writes here via Gradle) + if [ "$FOUND" = false ]; then + BENCH_JSON=$(find "$ROOT/benchmark/build/outputs" \ + -path "*connected_android_test_additional_output*" \ + -name "*.json" -newer "$ANDROID_STAMP" 2>/dev/null | head -1) + if [ -n "$BENCH_JSON" ] && [ -f "$BENCH_JSON" ]; then + cat "$BENCH_JSON" + FOUND=true + fi + fi + + # 3. On-device benchmark JSON (legacy / older AndroidX Benchmark versions) + if [ "$FOUND" = false ]; then BENCH_JSON=$(adb shell "ls /sdcard/Download/*benchmark*json 2>/dev/null" 2>/dev/null | head -1 | tr -d '\r') if [ -n "$BENCH_JSON" ]; then adb shell "cat '$BENCH_JSON'" 2>/dev/null - else - echo "Android benchmark ran but results not found." + FOUND=true fi fi + + if [ "$FOUND" = false ]; then + echo "Android benchmark ran but results not found." + fi echo "" else echo "=== Skipping Android benchmark (no device/emulator connected) ==="