BenchmarkRule.Scope
public final inner class BenchmarkRule.Scope extends MicrobenchmarkScope
| java.lang.Object | ||
| ↳ | androidx.benchmark.MicrobenchmarkScope | |
| ↳ | androidx.benchmark.junit4.BenchmarkRule.Scope |
Handle used for controlling measurement during measureRepeated.
Summary
Public methods |
|
|---|---|
final @NonNull T |
<T extends Object> This method is deprecated. Renamed to runWithMeasurementDisabled to clarify all measurements are paused |
Inherited methods |
||||||
|---|---|---|---|---|---|---|
|
Public methods
public final @NonNull T <T extends Object>runWithTimingDisabled(@NonNull Function0<@NonNull T> block)
Disable measurement for a block of code.
Used for disabling timing/measurement for work that isn't part of the benchmark:
-
When constructing per-loop randomized inputs for operations with caching,
-
Controlling which parts of multi-stage work are measured (e.g. View measure/layout)
-
Per-loop verification
import androidx.benchmark.junit4.measureRepeated @Test fun bitmapProcessing() = benchmarkRule.measureRepeated { val input: Bitmap = runWithMeasurementDisabled { constructTestBitmap() } processBitmap(input) }