BenchmarkState.Companion

public static class BenchmarkState.Companion


Summary

Nested types

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

Public methods

static final void
@BenchmarkState.Companion.ExperimentalExternalReport
reportData(
    @NonNull String className,
    @NonNull String testName,
    @IntRange(from = 0) long totalRunTimeNs,
    @NonNull List<@NonNull Long> dataNs,
    @IntRange(from = 0) int warmupIterations,
    @IntRange(from = 0) long thermalThrottleSleepSeconds,
    @IntRange(from = 1) int repeatIterations
)

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

Public methods

reportData

Added in 1.0.0
@BenchmarkState.Companion.ExperimentalExternalReport
public static final void reportData(
    @NonNull String className,
    @NonNull String testName,
    @IntRange(from = 0) long totalRunTimeNs,
    @NonNull List<@NonNull Long> dataNs,
    @IntRange(from = 0) int warmupIterations,
    @IntRange(from = 0) long thermalThrottleSleepSeconds,
    @IntRange(from = 1) int repeatIterations
)

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
@NonNull String className

Name of class the benchmark runs in

@NonNull String testName

Name of the benchmark

@IntRange(from = 0) long totalRunTimeNs

The total run time of the benchmark

@NonNull List<@NonNull Long> dataNs

List of all measured timing results, in nanoseconds

@IntRange(from = 0) int warmupIterations

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

@IntRange(from = 0) long thermalThrottleSleepSeconds

Number of seconds benchmark was paused during thermal throttling.

@IntRange(from = 1) int repeatIterations

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