Search code examples
javaeclipsebenchmarkingjmh

"No matching benchmarks" when running JMH from main in eclipse


I wanted to try out the new feature of JMH by running it as Java Application in eclipse. I imported and built jmh-samples project. Compiled classes ended in /jmh-samples/target/generated-sources/annotations, there are several JARs in /target/ and running microbenchmarks.jar from command line works as usual.

However when I execute main I always get

No matching benchmarks. Miss-spelled regexp?

Any ideas? I am using version 0.3


Solution

  • Okay, so looks like by default jmh looks for generated classes under META-INF/Microbenchmarks, which maven build puts under root of the project. However root of the eclipse project is not on the classpath, so executing it in IDE results in "no benchmarks found".

    I got it running following way:

    1. mvn clean package (using external maven installation, not embded in eclipse)
    2. Right-click on jmh-samples project, select "Build Path -> Use as a source folder"
    3. You can now run any of the benchmarks from jmh-samples as Java Application in eclipse

    On the downside you get like 1000+ "errors" in Problems view, since eclipse gets confused with auto-generated files, but oh well, at least it works.