Detect if Macrobenchmark is running

19 Views Asked by At

Is there a way to detect when MacroBenchmark is running?
Ideally I wish to use this check to connect to a WireMock server running on my host machine.

1

There are 1 best solutions below

0
On

Figured it out myself.

We can provide an intent with some extra data

@Test
fun scrollList() {
    benchmarkRule.measureRepeated(
        // ...
        setupBlock = {
            // Before starting to measure, navigate to the UI to be measured
            val intent = Intent("$packageName.RECYCLER_VIEW_ACTIVITY")
            intent.putExtra(…, …)
            startActivityAndWait(intent)
        }
    ) {
        ...
    }
}