@Param support for enum

Joe Kearney mail at joekearney.co.uk
Mon May 26 15:59:02 UTC 2014


Hi Aleksey,

I will reply properly to your earlier email and try out the new code drop.
However I was hoping for an no-arg version of @Param that would implicitly
pick out all enum values so as not to require keeping the strings in the
@Param.value in sync with the enum type names. I can look at supplyng a
patch for that if you'd like.

Describing -- yes. But actually implementing them in the enum is an
> abuse of the language feature, IMO.


I agree. One way that I've used this pattern in benchmarks is for the enum
value to be a supplier or creator of the thing to be benchmarked. In this
way it becomes a sort @Param-specific setup. This is nice and concise, and
clear if @Param just iterates over the enum values. The questions around
how to do @setup per benchmark are the same as for real @Setup methods, I
believe.

Thanks,
Joe


On 26 May 2014 16:32, Aleksey Shipilev <aleksey.shipilev at oracle.com> wrote:

> On 05/24/2014 11:50 AM, Aleksey Shipilev wrote:
> > On 05/23/2014 08:19 PM, Joe Kearney wrote:
> >> Would you be interested in having @Param support enum fields? By
> >> comparison, Caliper interprets @Param with no args to mean all enum
> values,
> >> and (I think) loads specific named enum values @Param("FOO", "BAR").
> >
> > Yeah, @Param-s for enum are accidentally missing. We can get it back.
>
> Recent code has the support for @Param(<enum>):
>   http://hg.openjdk.java.net/code-tools/jmh/rev/577497912199
>
> Please test (you will need to build "bleeding edge" 1.0-SNAPSHOT at the
> moment), and report your experiences.
>
> Thanks,
> -Aleksey.
>


More information about the jmh-dev mailing list