Creating benchmarks "dynamically"
Aleksey Shipilev
aleksey.shipilev at gmail.com
Thu Aug 25 15:34:41 UTC 2016
On 08/24/2016 11:36 PM, Kannan Goundan wrote:
> Unfortunately, I don't think I can pick my set of arguments to @Param at
> runtime (since they need to be seen by the annotation processing tool).
>
> Another alternative would be to dynamically generate some Java code, run
> 'javac' on it (with annotation processing), load the class, then run JMH.
> Seems a little clunky, though.
>
> Are there lower-level JMH APIs I can use to do things more directly?
Not "low-level", but the actual Java API can be used to override the
benchmark parameters. Since you seem to be writing your own launcher
anyway, that might be the best option. Make implementation class name
and input file name as @Params, and set those params via the API.
See the same example Henri referenced, at the bottom:
http://hg.openjdk.java.net/code-tools/jmh/file/
2e5a7761ce12/jmh-samples/src/main/java/org/openjdk/jmh/
samples/JMHSample_27_Params.java#l97
Thanks,
-Aleksey
More information about the jmh-dev
mailing list