Package org.openjdk.jmh.infra
Class Blackhole
java.lang.Object
org.openjdk.jmh.infra.Blackhole
Black Hole.
Black hole "consumes" the values, conceiving no information to JIT whether the value is actually used afterwards. This can save from the dead-code elimination of the computations resulting in the given values.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidconsume(boolean bool) Consume object.final voidconsume(byte b) Consume object.final voidconsume(char c) Consume object.final voidconsume(double d) Consume object.final voidconsume(float f) Consume object.final voidconsume(int i) Consume object.final voidconsume(long l) Consume object.final voidconsume(short s) Consume object.final voidConsume object.static voidconsumeCPU(long tokens) Consume some amount of time tokens.voidMake any consumed data begone.
-
Field Details
-
b1
public volatile byte b1 -
bool1
public volatile boolean bool1 -
c1
public volatile char c1 -
s1
public volatile short s1 -
i1
public volatile int i1 -
l1
public volatile long l1 -
f1
public volatile float f1 -
d1
public volatile double d1 -
b2
public byte b2 -
bool2
public boolean bool2 -
c2
public char c2 -
s2
public short s2 -
i2
public int i2 -
l2
public long l2 -
f2
public float f2 -
d2
public double d2 -
obj1
-
nullBait
public volatile org.openjdk.jmh.infra.BlackholeL2 nullBait -
tlr
public int tlr -
tlrMask
public volatile int tlrMask
-
-
Constructor Details
-
Blackhole
-
-
Method Details
-
evaporate
Make any consumed data begone. WARNING: This method should only be called by the infrastructure code, in clearly understood cases. Even though it is public, it is not supposed to be called by users.- Parameters:
challengeResponse- arbitrary string
-
consume
Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.- Parameters:
obj- object to consume.
-
consume
public final void consume(byte b) Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.- Parameters:
b- object to consume.
-
consume
public final void consume(boolean bool) Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.- Parameters:
bool- object to consume.
-
consume
public final void consume(char c) Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.- Parameters:
c- object to consume.
-
consume
public final void consume(short s) Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.- Parameters:
s- object to consume.
-
consume
public final void consume(int i) Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.- Parameters:
i- object to consume.
-
consume
public final void consume(long l) Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.- Parameters:
l- object to consume.
-
consume
public final void consume(float f) Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.- Parameters:
f- object to consume.
-
consume
public final void consume(double d) Consume object. This call provides a side effect preventing JIT to eliminate dependent computations.- Parameters:
d- object to consume.
-
consumeCPU
public static void consumeCPU(long tokens) Consume some amount of time tokens. This method does the CPU work almost linear to the number of tokens. The token cost may vary from system to system, and may change in future. (Translation: it is as reliable as we can get, but not absolutely reliable). See JMH samples for the complete demo, and core benchmarks for the performance assessments.- Parameters:
tokens- CPU tokens to consume
-