JMH v0.6

Dmitry Chuyko dmitry.chuyko at oracle.com
Mon Apr 28 10:15:02 UTC 2014


Hello,

On 04/25/2014 11:11 AM, Aleksey Shipilev wrote:
> Hi there,
> ..........................
>   * Since some users were burned on this, "new BlackHole()" is forbidden
> now, and will throw an exception at runtime [2]. Use injected Blackholes
> instead.
What about '@State MyState extends BlackHole'?
It is sometimes convenient to encapsulate some black hole inside state. 
For example consider passing this stream to some constructor:

final OutputStream nullos = new OutputStream() {
     @Override
     public void write(int b) throws IOException {
         consume(b);
     }
     @Override
     public void write(byte[] b, int off, int len) throws IOException {
         consume(b);
     }
};

Dmitry
>
> ..........................
> Enjoy!
>
> Thanks,
> -Aleksey.
>
> [1]
> http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_28_BlackholeHelpers.java
> [2] http://hg.openjdk.java.net/code-tools/jmh/rev/de0365d7e4d0
> [3] http://hg.openjdk.java.net/code-tools/jmh/rev/292b20d8fa97, etc
> [4] http://hg.openjdk.java.net/code-tools/jmh/rev/cde312963a3d
> [5]
> http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_29_StatesDAG.java



More information about the jmh-dev mailing list