Liking cljdoc? Tell your friends :D

criterium.blackhole

Blackhole for preventing dead code elimination (DCE) in benchmarks.

Two modes are supported:

Compiler Blackhole (JVM 17+) Uses -XX:CompileCommand=blackhole,criterium.blackhole.Blackhole::consume to mark consume methods as compiler blackholes. Zero overhead.

Runtime Blackhole (JVM < 17 or flag not present) Uses volatile fields and XOR-based impossible conditions. ~3ns overhead.

Mode is detected at namespace load time. Use mode to check which is active.

Blackhole for preventing dead code elimination (DCE) in benchmarks.

Two modes are supported:

Compiler Blackhole (JVM 17+)
Uses -XX:CompileCommand=blackhole,criterium.blackhole.Blackhole::consume
to mark consume methods as compiler blackholes. Zero overhead.

Runtime Blackhole (JVM < 17 or flag not present)
Uses volatile fields and XOR-based impossible conditions. ~3ns overhead.

Mode is detected at namespace load time. Use `mode` to check which is active.
raw docstring

compiler-blackhole-available?clj

(compiler-blackhole-available?)

True if the JVM supports compiler blackholes (version >= 17).

True if the JVM supports compiler blackholes (version >= 17).
sourceraw docstring

compiler-blackhole-enabled?clj

(compiler-blackhole-enabled?)

True if compiler blackhole mode is active.

True if compiler blackhole mode is active.
sourceraw docstring

consumecljmacro

(consume x)

Consume a value to prevent dead code elimination.

In compiler mode (JVM 17+ with flag), expands to static method call with zero overhead. In runtime mode, expands to instance method call with ~3ns overhead.

The value is evaluated exactly once.

Consume a value to prevent dead code elimination.

In compiler mode (JVM 17+ with flag), expands to static method call with zero overhead.
In runtime mode, expands to instance method call with ~3ns overhead.

The value is evaluated exactly once.
sourceraw docstring

evaporateclj

(evaporate)

Clear any retained object references from the runtime blackhole. Call after measurement to prevent object retention. No-op in compiler mode.

Clear any retained object references from the runtime blackhole.
Call after measurement to prevent object retention.
No-op in compiler mode.
sourceraw docstring

modeclj

(mode)

Return the active blackhole mode: :compiler or :runtime.

Return the active blackhole mode: :compiler or :runtime.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close