Quantcast
Channel: User blacktide - Stack Overflow
Viewing all articles
Browse latest Browse all 49

Answer by blacktide for JMH Unable to find the resource: /META-INF/BenchmarkList

$
0
0

If anyone is using Gradle, add the jmh-gradle-plugin to your plugins block:

plugins {    id 'java'    id 'me.champeau.jmh' version '0.6.8'}

Then add all of the following in your dependencies block (check the latest version of JMH on Maven here):

dependencies {    jmh 'org.openjdk.jmh:jmh-core:1.36'    jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.36'    // this is the line that solves the missing /META-INF/BenchmarkList error    jmhAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.36'}

Then just use the following to run your benchmarks through Gradle:

./gradlew jmh

Running through your IDE

If you also want to run the benchmarks from within your IDE instead of through Gradle, you can do either of the following:

Option 1 - main method

Just use a main method with no additional configuration and your IDE will respect your annotation configuration:

@BenchmarkMode(Mode.AverageTime)@OutputTimeUnit(TimeUnit.MILLISECONDS)@State(Scope.Benchmark)@Fork(value = 1)@Warmup(iterations = 5, timeUnit = TimeUnit.MILLISECONDS, time = 5000)@Measurement(iterations = 5, timeUnit = TimeUnit.MILLISECONDS, time = 5000)public class MyBenchmark {    public static void main(String[] args) throws RunnerException {        Options options = new OptionsBuilder()            .include(MyBenchmark.class.getSimpleName())            .build();        new Runner(options).run();    }    // benchmarks omitted}

Option 2 - Install JMH Plugin

If you're using IntelliJ, install the JMH Java Microharness Benchmark Plugin from the Preferences > Plugins section, then you can omit your main method altogether and IntelliJ will give you a run button next to your class name:

JMH benchmark in IntelliJ


Viewing all articles
Browse latest Browse all 49

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>