# MicrobenchmarkConfig

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

*** ** * ** ***


```
@ExperimentalBenchmarkConfigApi
class MicrobenchmarkConfig
```

<br />

*** ** * ** ***

Experimental config object for microbenchmarks for defining custom metrics, tracing behavior, and profiling, which overrides options set in [instrumentation arguments](https://developer.android.com/topic/performance/benchmarking/microbenchmark-instrumentation-args).

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/benchmark/MicrobenchmarkConfig#MicrobenchmarkConfig(kotlin.collections.List,kotlin.Boolean,kotlin.Boolean,androidx.benchmark.ProfilerConfig,kotlin.Int,kotlin.Int)( metrics: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/benchmark/MetricCapture>, traceAppTagEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, perfettoSdkTracingEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, profiler: https://developer.android.com/reference/kotlin/androidx/benchmark/ProfilerConfig?, warmupCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html?, measurementCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html? )` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html?` | `https://developer.android.com/reference/kotlin/androidx/benchmark/MicrobenchmarkConfig#measurementCount()` Number of measurements to perform, leave `null` for default behavior. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/benchmark/MetricCapture>` | `https://developer.android.com/reference/kotlin/androidx/benchmark/MicrobenchmarkConfig#metrics()` Timing metrics for primary phase, post-warmup |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/benchmark/MicrobenchmarkConfig#perfettoSdkTracingEnabled()` Set to true to enable capture of tracing-perfetto trace events, such as in Compose composition tracing. |
| `https://developer.android.com/reference/kotlin/androidx/benchmark/ProfilerConfig?` | `https://developer.android.com/reference/kotlin/androidx/benchmark/MicrobenchmarkConfig#profiler()` Optional profiler to be used after the primary timing phase. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/benchmark/MicrobenchmarkConfig#traceAppTagEnabled()` Set to true to enable capture of `trace("foo") {}` blocks in the output Perfetto trace. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html?` | `https://developer.android.com/reference/kotlin/androidx/benchmark/MicrobenchmarkConfig#warmupCount()` Number of non-measured warmup iterations to perform, leave `null` to determine automatically. |

## Public constructors

### MicrobenchmarkConfig

```
MicrobenchmarkConfig(
    metrics: List<MetricCapture> = if (Arguments.cpuEventCounterMask != 0) {
            listOf(
                TimeCapture(),
                CpuEventCounterCapture(
                    cpuEventCounter = MicrobenchmarkPhase.cpuEventCounter,
                    mask = Arguments.cpuEventCounterMask,
                    validateMeasurements = true,
                ),
            )
        } else {
            listOf(TimeCapture())
        },
    traceAppTagEnabled: Boolean = false,
    perfettoSdkTracingEnabled: Boolean = false,
    profiler: ProfilerConfig? = null,
    warmupCount: Int? = null,
    measurementCount: Int? = null
)
```

## Public properties

### measurementCount

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

```
val measurementCount: Int?
```

Number of measurements to perform, leave `null` for default behavior.

### metrics

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

```
val metrics: List<MetricCapture>
```

Timing metrics for primary phase, post-warmup

Defaults to `https://developer.android.com/reference/kotlin/androidx/benchmark/TimeCapture`.

### perfettoSdkTracingEnabled

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

```
val perfettoSdkTracingEnabled: Boolean
```

Set to true to enable capture of tracing-perfetto trace events, such as in Compose composition tracing.

Defaults to false to minimize interference.

### profiler

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

```
val profiler: ProfilerConfig?
```

Optional profiler to be used after the primary timing phase.

### traceAppTagEnabled

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

```
val traceAppTagEnabled: Boolean
```

Set to true to enable capture of `trace("foo") {}` blocks in the output Perfetto trace.

Defaults to false to minimize interference.

### warmupCount

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

```
val warmupCount: Int?
```

Number of non-measured warmup iterations to perform, leave `null` to determine automatically.