Open PeterReiter opened 8 years ago
@PeterReiter running benchmarks directly from the IDE is not supported (in other words you use IDE only to write benchmarks). You first need to generate a jar with benchmarks (which you can do by running jmhJar
) task and then you would be able to execute benchmarks by:
gradlew jmh
(which internally calls jmhJar
)java -jar build/libs/project-jmh.jar
The advantage of the second approach is that you can specify any command line args for JMH without changing build.gradle
file.
So if you would like to run just a JMHSample_25_API_GA
via its main method (not as a benchmark). Then you can do the following:
./gradlew jmhJar
java -cp build/libs/xxx-jmh.jar org.openjdk.jmh.samples.JMHSample_25_API_GA
there is a solution explained here: https://stackoverflow.com/a/71286156
for using jmh to also work with the intellij plugin https://github.com/artyushov/idea-jmh-plugin you also have to add
dependencies {
jmh 'org.openjdk.jmh:jmh-core:+'
jmh 'org.openjdk.jmh:jmh-generator-annprocess:+'
jmhAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:+'
}
to your build script. i am not sure why, but i think this fix could easily be employed by the gradle plugin to also just perform these operation
Hello,
I'm using the plugin in combination with IntelliJ IDEA 15.0.4 and I try to run the example JMHSample_25_API_GA, which uses the JMH API.
But when I try to execute the main() method I always get the following error:
Exception in thread "main" java.lang.RuntimeException: ERROR: Unable to find the resource: /META-INF/BenchmarkList
My build.gradle file:
Running the task jmhJar, creates all the needed classes and also the BenchmarkList, in the directory jmh-generated-classes/META-INF
Maybe someone can help me with my problem, best regards Peter