jmh 0.6. I have jmh-core, jmh-generator-annprocess, jmh-generator-reflection as dependencies.
Firstly, the documentation is bad, unfortunately. First, I use gradle, not maven, so using the maven archetype is not an option.
Secondly, I want to use the Java API, not the command line.
My very simple code:
public final class TestBenchmark { private static final int COUNT = 100_000; private static final List<Integer> LIST = new ArrayList<>(); static { for (int i = 0; i < COUNT; i++) LIST.add(i); } @GenerateMicroBenchmark public void foreachLoop() { int dummy; for (final int i: LIST) dummy = i; } @GenerateMicroBenchmark public void forLoop() { int dummy; final int size = LIST.size(); for (int i = 0; i < size; i++) dummy = LIST.get(i); } public static void main(final String... args) throws RunnerException { final Options options = new OptionsBuilder() .forks(1) .warmupIterations(1) .measurementIterations(20) .verbosity(VerboseMode.EXTRA) .build(); new Runner(options).run(); } }
Since I don't have .include() , this means .* As a regular expression, so all benchmarks. This is the only class I have in my project.
But no: "no benchmarks."
So, as a last resort, I tried to create a META-INF/MicroBenchmarks , as suggested elsewhere; content, class name:
com.github.parboiled1.grappa.TestBenchmark
but it does not work:
Exception in thread "main" java.lang.IllegalStateException: Mismatched format for the line: com.github.parboiled1.grappa.TestBenchmark
and the format of this file is, of course, not documented.
But I do not want to use this file to start; I want to specify a list of classes to run.
How to do it?
java jmh
fge
source share