Exception in Runner when more than two params declared
Robert Wicke
rwicke at gmail.com
Mon Apr 28 20:06:03 UTC 2014
Hi,
Using jmh 0.6 I ran into an issue in Runner when trying to execute a benchmark class that annotates more than two fields with @Param. I get an exception like the following:
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:342)
at java.util.TreeSet.addAll(TreeSet.java:312)
at org.openjdk.jmh.runner.Runner.run(Runner.java:208)
at org.sample.MyBenchmark.main(MyBenchmark.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
The problem is in the explodeAllParams method in Runner. The following one-liner fixes it:
diff -r fc6fd603598d jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java Mon Apr 28 23:12:18 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java Mon Apr 28 20:58:41 2014 +0100
@@ -303,6 +303,7 @@
}
ps.clear();
ps.addAll(newPs);
+ newPs.clear();
}
}
return ps;
— Rob
More information about the jmh-dev
mailing list