Status Update
Comments
cc...@google.com <cc...@google.com> #2
However this is not working, because each @Test function seems to be running in a different process, therefore the previous result is lost from the ResultWriter.
Each test method running in its own process sounds like you are
Typically that's not how tests run by default, if I add the following to a macrobench test method, outside of measureRepeated:
println("index is " + index++)
With index defined in a companion object, I see different values printed each time.
We could make this work by optionally outputting a different json file for each test, but is there a reason you're enabling test orchestration? Generally it's used to isolate each test from one another, but that shouldn't be necessary for macrobenchmarks - all the interesting behavior is happening in the target process, which macrobench kills in between each test.
Macrobench tests sort of act already as a test orchestrator in this way, and benefit from avoiding duplicate work across tests.
cs...@supercharge.io <cs...@supercharge.io> #3
Thanks very much! Indeed that was the problem. We use the Test Orchestrator for all of our modules. I turned it to HOST
for the benchmark module, and it solved the issue.
Maybe it could be noted in the doc, or a warning could be displayed, that we should not use Test Orchestrator for benchmarks.
ap...@google.com <ap...@google.com> #4
Branch: androidx-main
commit ee1d2f98cecaf51a037e267af31b94e054ee2a3c
Author: Chris Craik <ccraik@google.com>
Date: Mon Mar 18 13:49:28 2024
Warn when test orchestrator is used
Test: TrivialKotlinBenchmark
Fixes: 286899049
Relnote: "Added a warning when test orchestrator is used in benchmark
modules, as this will cause per-module output JSON files to be
repeatedly overwritten."
Test orchestrator instrumentation arg observed in standalone test
module, didn't add test scenario as it would require adding test
orchestration prebuilts as well as a new module to the androidx repo.
Change-Id: Ia1af6a178c9ef1c7e0dd80f735749eb97f416d7e
M benchmark/benchmark-common/src/main/java/androidx/benchmark/Arguments.kt
na...@google.com <na...@google.com> #5
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.benchmark:benchmark-common:1.3.0-alpha03
Description
Component used: Macrobenchmark
Version used: 1.2.0-alpha06
Devices/Android versions reproduced on: Pixel 6 Android 13
When having a benchmark with multiple
@Test
functions, it seems that the finalbenchmarkData.json
file only contains one benchmark result in thebenchmarks
JSON array.This can be reproduced with the code taken from the Baseline profile documentation .
Digging in to the benchmark sources, this should work on a first look, because ResultWriter is global
object
, and collects all the previous benchmark results in a list. However this is not working, because each@Test
function seems to be running in a different process, therefore the previous result is lost from theResultWriter
.