@Param support for enum

Joe Kearney mail at joekearney.co.uk
Mon Jun 9 20:02:05 UTC 2014


Hi,

Aleksey, as discussed here is the patch. It includes the main change in
BenchmarkGenerator and StateObjectHandler, plus runtime and compile-time
tests.

Couple of notes:
* I factored out addParameterValuesToGroup because the code was duplicated
between step 1 and 2 of @Param discovery.
* I'd advocate renaming getEnumConstants to getEnumConstantNames, but maybe
that's just a matter of taste.
* I'm pretty sure there's a typo-bug in BenchmarkGenerator line 311, it
should loop over fields from state#getFields, not over fields in clazz, an
unused local variable warning.

Please let me know any feedback you have. I'm around tonight for any
changes you'd like to make.

​Thanks,
Joe​




On 5 June 2014 21:45, Aleksey Shipilev <aleksey.shipilev at oracle.com> wrote:

> Hi Joe,
>
> On 06/06/2014 12:02 AM, Joe Kearney wrote:
> > The only sensible place to expand the set of values seems to be in
> > Runner#explodeAllParams, as you pointed to, generating a BenchmarkRecord
> > for each value. In order to get the enum constants we'll need a handle
> > on the type token of the enum, which we can get through the type of the
> > field, which we can get through the type of the benchmark class.
>
> I only pointed to Runner#explodeAllParams as the place where you would
> need to place a runtime check for empty arguments (remember we were
> talking about redoing the "default" parameters contracts). However, you
> may just do the checks during the compilation in
> StateObjectHandler#checkParams.
>
> I would think the better place to treat enums would be to read the
> default parameters' values during the generation, pretending as if the
> user listed all the values in the annotation explicitly. Here:
>
>
> http://hg.openjdk.java.net/code-tools/jmh/file/6ee04bc18969/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java#l445
>
> Thanks,
> -Aleksey.
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: param-for-enums.patch
Type: text/x-patch
Size: 14599 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/jmh-dev/attachments/20140609/6b9e1b6d/param-for-enums-0001.patch>


More information about the jmh-dev mailing list