fix: improve Android benchmark result discovery in run_all.sh
Three issues fixed: - Replace fragile -newer comparison against the script file (breaks after any script edit) with a timestamp file created just before the Gradle task runs. - Search connected_android_test_additional_output for pulled benchmark JSON (where AndroidX Benchmark actually writes results via Gradle). - Extract benchmark data from XML via CDATA parsing instead of dumping raw XML, consistent with the JVM and K/Native sections. https://claude.ai/code/session_01WSNE6QKiYM2ZutQD2UihCW
This commit is contained in:
@@ -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 '/<!\[CDATA\[/,/\]\]>/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) ==="
|
||||
|
||||
Reference in New Issue
Block a user