# BenchmarkRule.Scope

Artifact: [androidx.benchmark:benchmark-junit4](https://developer.android.com/jetpack/androidx/releases/benchmark) [View Source](https://cs.android.com/search?q=file:androidx/benchmark/junit4/BenchmarkRule.kt+class:androidx.benchmark.junit4.BenchmarkRule.Scope) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/benchmark#1.0.0)

*** ** * ** ***


```
inner class BenchmarkRule.Scope : MicrobenchmarkScope
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.benchmark.MicrobenchmarkScope](https://developer.android.com/reference/kotlin/androidx/benchmark/MicrobenchmarkScope) ||
|   | ↳ | [androidx.benchmark.junit4.BenchmarkRule.Scope](https://developer.android.com/reference/kotlin/androidx/benchmark/junit4/BenchmarkRule.Scope) |

*** ** * ** ***

Handle used for controlling measurement during `https://developer.android.com/reference/kotlin/androidx/benchmark/junit4/package-summary#(androidx.benchmark.junit4.BenchmarkRule).measureRepeated(kotlin.Function1)`.

## Summary

| ### Public functions |
|---|---|
| `inline T` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> [runWithTimingDisabled](https://developer.android.com/reference/kotlin/androidx/benchmark/junit4/BenchmarkRule.Scope#runWithTimingDisabled(kotlin.Function0))(block: () -> T)` **This function is deprecated.** Renamed to runWithMeasurementDisabled to clarify all measurements are paused |

### Inherited functions

From [androidx.benchmark.MicrobenchmarkScope](https://developer.android.com/reference/kotlin/androidx/benchmark/MicrobenchmarkScope) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/benchmark/MicrobenchmarkScope#pauseMeasurement()()`

Pause measurement until the next call to `https://developer.android.com/reference/kotlin/androidx/benchmark/MicrobenchmarkScope#resumeMeasurement()`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/benchmark/MicrobenchmarkScope#resumeMeasurement()()`

Resume measurement after a call to `https://developer.android.com/reference/kotlin/androidx/benchmark/MicrobenchmarkScope#pauseMeasurement()`
`inline T` `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/benchmark/MicrobenchmarkScope#runWithMeasurementDisabled(kotlin.Function0)(block: () -> T)`

Disable measurement for a block of code.

## Public functions

### runWithTimingDisabled

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/benchmark#1.0.0) Deprecated in [1.4.0](https://developer.android.com/jetpack/androidx/releases/benchmark#1.4.0)

```
inline fun <T : Any?> [runWithTimingDisabled](https://developer.android.com/reference/kotlin/androidx/benchmark/junit4/BenchmarkRule.Scope#runWithTimingDisabled(kotlin.Function0))(block: () -> T): T
```

> [!CAUTION]
> **This function is deprecated.**   
> Renamed to runWithMeasurementDisabled to clarify all measurements are paused, use this instead:
>
> ```kotlin
> runWithMeasurementDisabled
> ```

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

```kotlin
import androidx.benchmark.junit4.measureRepeated

@Test
fun bitmapProcessing() = benchmarkRule.measureRepeated {
    val input: Bitmap = runWithMeasurementDisabled { constructTestBitmap() }
    processBitmap(input)
}
```