# 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)

*** ** * ** ***


```
public static class 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/androidx/benchmark/BlackHole#consume(kotlin.Byte)`.

## Summary

| ### Public fields |
|---|---|
| `static @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/benchmark/BlackHole` | `https://developer.android.com/reference/androidx/benchmark/BlackHole#INSTANCE()` |

| ### Public methods |
|---|---|
| `static final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/FastNative.html https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html value)` Prevent dead code elimination of `https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Any)` and its computation. |
| `static final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Boolean)(boolean value)` Prevent dead code elimination of `https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Boolean)` and its computation. |
| `static final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Byte)(byte value)` Prevent dead code elimination of `https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Byte)` and its computation. |
| `static final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Char)(char value)` Prevent dead code elimination of `https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Char)` and its computation. |
| `static final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Double)(double value)` Prevent dead code elimination of `https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Double)` and its computation. |
| `static final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Float)(float value)` Prevent dead code elimination of `https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Float)` and its computation. |
| `static final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Int)(int value)` Prevent dead code elimination of `https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Int)` and its computation. |
| `static final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Long)(long value)` Prevent dead code elimination of `https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Long)` and its computation. |
| `static final external void` | `@https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative.html https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Short)(short value)` Prevent dead code elimination of `https://developer.android.com/reference/androidx/benchmark/BlackHole#consume(kotlin.Short)` and its computation. |

## Public fields

### INSTANCE

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

```
public static @NonNull BlackHole INSTANCE
```

## Public methods

### consume

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

```
@FastNative
public static final external void consume(@NonNull Object value)
```

Prevent dead code elimination of `https://developer.android.com/reference/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
public static final external void consume(boolean value)
```

Prevent dead code elimination of `https://developer.android.com/reference/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
public static final external void consume(byte value)
```

Prevent dead code elimination of `https://developer.android.com/reference/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
public static final external void consume(char value)
```

Prevent dead code elimination of `https://developer.android.com/reference/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
public static final external void consume(double value)
```

Prevent dead code elimination of `https://developer.android.com/reference/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
public static final external void consume(float value)
```

Prevent dead code elimination of `https://developer.android.com/reference/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
public static final external void consume(int value)
```

Prevent dead code elimination of `https://developer.android.com/reference/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
public static final external void consume(long value)
```

Prevent dead code elimination of `https://developer.android.com/reference/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
public static final external void consume(short value)
```

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