Running benchmark with main method from the generated jar
Luis IBANEZ
luis.ibanez at univ-nantes.fr
Thu Apr 3 09:10:10 UTC 2014
> The attachments are stripped on this list, but I got a personal copy :)
See below:
> On 04/02/2014 04:30 PM, Luis IBANEZ wrote:
>> When I add the "parent(new CommandLineOptions(args)" line, if i do java
-cp microbenchmarks.jar mypackage/mysubpack/MyClass -i 5 -wi 5 It does
take in account the -i and -wi switches, but, it ignores that I want to
execute "MyClass" and starts executing all benchmarks with
these
>> parameters, like if i were using the normal "java -jar
>> microbenchmark.jar"
>> call without filtering.
> Of course it does not, because "parent" means "if the option is not set
here, ask the parent". In this case, we already overridden the parent
settings with our own. Scratch off the methods in OptionsBuilder chain
if you want some options to be overridable. (Maybe that will mean you
will get the only call to CommandLineOptions, so then you can feed it
straight to the Runner). If you want to provide default options, then
use annotations.
OK, now I understand how it works. My mistake was that i was using -cp
MyClass to execute the main, and I did not specify the class with the
benchmark methods. Therefore, the default ".*" was taken. In this
particular case, executing the intutitive:
Options baseOpts = new OptionsBuilder()
.parent(new CommandLineOptions(args))
.include("mypackage.myclass.*")
.build();
does not work because the include is an add to a set of methods, not a put
in a map. The above Options will have [.*,mypackage.myClass.*] as included
benchmarks.
> This is a problem for the forked runs: your static is initialized in
host VM, but then JMH forks off the VM for measurement, and static is
obviously not initialized there. If you want to fix your example in a
simple way, read the properties in static initializer.
> Or, use @Param. Any reason why you are not using it?
At first, plain ignorance, I missed the comment in code sample 26 about
the -p switch to set parameters via CLI
I changed my example to that (attachment), but I hit another rock: if you
annotate more than two class variables with @Param, this exception jumps:
Exception in thread "main" java.lang.IllegalStateException: Comparing
actual params with different key sets.
at org.openjdk.jmh.runner.ActualParams.compareTo(ActualParams.java:48) at
org.openjdk.jmh.runner.BenchmarkRecord.compareTo(BenchmarkRecord.java:195)
at
org.openjdk.jmh.runner.BenchmarkRecord.compareTo(BenchmarkRecord.java:38)
at java.util.TreeMap.put(TreeMap.java:560)
at java.util.TreeSet.add(TreeSet.java:255)
at java.util.AbstractCollection.addAll(AbstractCollection.java:334) at
java.util.TreeSet.addAll(TreeSet.java:312)
at org.openjdk.jmh.runner.Runner.run(Runner.java:216)
at org.openjdk.jmh.Main.main(Main.java:72)
> -Aleksey.
More information about the jmh-dev
mailing list