Creating a Blackhole
Andrew Brampton
me at bramp.net
Thu Jun 18 16:17:42 UTC 2015
I have a complex benchmark, that takes >1 hour to run. I kept hitting an
issue where the benchmark would crash during one of the setup/teardown
phase (due to mistakes in my code). So I figured why don't I unit test my
benchmark, to ensure the assumptions I make hold true.
During my unit tests I wanted to create a Blackhole to pass to one of the
benchmark methods. However, I found out that I'm not allowed to create a
Blackhole: IllegalStateException("Blackholes should not be instantiated
directly.").
I can either do a nasty hack to create the Blackhole, or I'm requesting you
add a new static method, Blackhole.newBlackholeYesIdoKnowWhatImDoing(), or
similar. Since in my case, I don't care about the benchmarking, and I'm
calling this from a single junit thread, and just testing the correctness
of my benchmark code. Alternatively if you create a Blackhole interface, I
could easily create mock blackhole, for my testing.
Suggestions?
thanks
Andrew
P.S For the curious, my code lives here https://github.com/bramp/unsafe
under unsafe-benchmark.
More information about the jmh-dev
mailing list