Creating a Blackhole
Andrew Brampton
me at bramp.net
Fri Jun 19 20:21:41 UTC 2015
Thanks Dawid, what I ended up doing was:
https://github.com/bramp/unsafe/blob/master/unsafe-benchmark/src/test/java/net/bramp/unsafe/JMHHelper.java
I would still like an official way to create a Blackhole, or be able to
mock a Blackhole, without hacks. I didn't find a bug tracker where I could
make this request.
thanks
Andrew
On 18 June 2015 at 09:25, Dawid Weiss <dawid.weiss at gmail.com> wrote:
> This may not be the quickest solution... but you can postprocess your
> bytecode after compilation (with asmlib, aspectj or whatever) and
> remove blackhole calls.
>
> With AspectJ it's a relatively easy call pointcut and an "around"
> advice that doesn't
> propagate the call. You could replace the default compiler with ajc
> and apply test-specific aspects during compilation.
>
> Dawid
>
> On Thu, Jun 18, 2015 at 6:17 PM, Andrew Brampton <me at bramp.net> wrote:
> > 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