# BlackHole

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

*** ** * ** ***


```
object BlackHole
```

<br />

*** ** * ** ***

Function calls which can be used to prevent optimization of results.

Both the Kotlin compiler and R8 can remove code you intend to benchmark. To prevent this, pass the result to `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Byte)`.

## Summary

| ### Public functions |
|---|---|
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Any)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)` Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Any)` and its computation. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Boolean)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Boolean)` and its computation. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Byte)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html)` Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Byte)` and its computation. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Char)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char/index.html)` Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Char)` and its computation. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Double)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)` Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Double)` and its computation. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Float)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Float)` and its computation. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Int)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Int)` and its computation. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Long)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Long)` and its computation. |
| `external https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Short)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-short/index.html)` Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Short)` and its computation. |

## Public functions

### consume

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

```
@FastNative
external fun consume(value: Any): Unit
```

Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Any)` and its computation.

### consume

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

```
@CriticalNative
external fun consume(value: Boolean): Unit
```

Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Boolean)` and its computation.

### consume

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

```
@CriticalNative
external fun consume(value: Byte): Unit
```

Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Byte)` and its computation.

### consume

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

```
@CriticalNative
external fun consume(value: Char): Unit
```

Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Char)` and its computation.

### consume

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

```
@CriticalNative
external fun consume(value: Double): Unit
```

Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Double)` and its computation.

### consume

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

```
@CriticalNative
external fun consume(value: Float): Unit
```

Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Float)` and its computation.

### consume

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

```
@CriticalNative
external fun consume(value: Int): Unit
```

Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Int)` and its computation.

### consume

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

```
@CriticalNative
external fun consume(value: Long): Unit
```

Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Long)` and its computation.

### consume

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

```
@CriticalNative
external fun consume(value: Short): Unit
```

Prevent dead code elimination of `https://developer.android.com/reference/kotlin/androidx/benchmark/BlackHole#consume(kotlin.Short)` and its computation.