BenchmarkState.Companion


object BenchmarkState.Companion


Summary

Nested types

@RequiresOptIn
@Retention(value = AnnotationRetention.BINARY)
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation BenchmarkState.Companion.ExperimentalExternalReport

Public functions

Unit
@BenchmarkState.Companion.ExperimentalExternalReport
reportData(
    className: String,
    testName: String,
    totalRunTimeNs: @IntRange(from = 0) Long,
    dataNs: List<Long>,
    warmupIterations: @IntRange(from = 0) Int,
    thermalThrottleSleepSeconds: @IntRange(from = 0) Long,
    repeatIterations: @IntRange(from = 1) Int
)

Hooks for benchmarks not using androidx.benchmark.junit4.BenchmarkRule to register results.

Public functions

reportData

Added in 1.0.0
@BenchmarkState.Companion.ExperimentalExternalReport
fun reportData(
    className: String,
    testName: String,
    totalRunTimeNs: @IntRange(from = 0) Long,
    dataNs: List<Long>,
    warmupIterations: @IntRange(from = 0) Int,
    thermalThrottleSleepSeconds: @IntRange(from = 0) Long,
    repeatIterations: @IntRange(from = 1) Int
): Unit

Hooks for benchmarks not using androidx.benchmark.junit4.BenchmarkRule to register results.

Results are printed to Studio console, and added to the output JSON file.

Parameters
className: String

Name of class the benchmark runs in

testName: String

Name of the benchmark

totalRunTimeNs: @IntRange(from = 0) Long

The total run time of the benchmark

dataNs: List<Long>

List of all measured timing results, in nanoseconds

warmupIterations: @IntRange(from = 0) Int

Number of iterations of warmup before measurements started. Should be no less than 0.

thermalThrottleSleepSeconds: @IntRange(from = 0) Long

Number of seconds benchmark was paused during thermal throttling.

repeatIterations: @IntRange(from = 1) Int

Number of iterations in between each measurement. Should be no less than 1.