androidx.benchmark

Classes

AndroidBenchmarkRunner

Instrumentation runner for benchmarks, used to increase stability of measurements and minimize interference.

BenchmarkRule

JUnit rule for benchmarking code on an Android device.

BenchmarkState

Control object for benchmarking in the code in Java.

IsolationActivity

Simple opaque activity used to reduce benchmark interference from other windows.

Extension functions summary

For BenchmarkRule
Unit

Benchmark a block of code.

Extension functions

measureRepeated

inline fun BenchmarkRule.measureRepeated(crossinline block: BenchmarkRule.Scope.() -> Unit): Unit

Benchmark a block of code.


@get:Rule
val benchmarkRule = BenchmarkRule();

@Test
fun myBenchmark() {
    ...
    benchmarkRule.measureRepeated {
        doSomeWork()
    }
    ...
}
Parameters
block The block of code to benchmark.