@ExperimentalBlackHoleApi
public static class BlackHole


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 BlackHole.consume.

Summary

Public fields

static @NonNull BlackHole

Public methods

static final external void

Prevent dead code elimination of value and its computation.

static final external void
consume(boolean value)

Prevent dead code elimination of value and its computation.

static final external void
consume(byte value)

Prevent dead code elimination of value and its computation.

static final external void
consume(char value)

Prevent dead code elimination of value and its computation.

static final external void
consume(double value)

Prevent dead code elimination of value and its computation.

static final external void
consume(float value)

Prevent dead code elimination of value and its computation.

static final external void
consume(int value)

Prevent dead code elimination of value and its computation.

static final external void
consume(long value)

Prevent dead code elimination of value and its computation.

static final external void
consume(short value)

Prevent dead code elimination of value and its computation.

Public fields

INSTANCE

Added in 1.3.0
public static @NonNull BlackHole INSTANCE

Public methods

consume

Added in 1.3.0
public static final external void consume(@NonNull Object value)

Prevent dead code elimination of value and its computation.

consume

Added in 1.3.0
public static final external void consume(boolean value)

Prevent dead code elimination of value and its computation.

consume

Added in 1.3.0
public static final external void consume(byte value)

Prevent dead code elimination of value and its computation.

consume

Added in 1.3.0
public static final external void consume(char value)

Prevent dead code elimination of value and its computation.

consume

Added in 1.3.0
public static final external void consume(double value)

Prevent dead code elimination of value and its computation.

consume

Added in 1.3.0
public static final external void consume(float value)

Prevent dead code elimination of value and its computation.

consume

Added in 1.3.0
public static final external void consume(int value)

Prevent dead code elimination of value and its computation.

consume

Added in 1.3.0
public static final external void consume(long value)

Prevent dead code elimination of value and its computation.

consume

Added in 1.3.0
public static final external void consume(short value)

Prevent dead code elimination of value and its computation.