Java 仅运行testMethod()的JMH基准测试

Java 仅运行testMethod()的JMH基准测试,java,jmh,Java,Jmh,公共类MyBenchmark{ @Benchmark public void otherMethod() { } @Benchmark public void sessionCreation() { } public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder().include(MyBenchmark.class.getSimpleName()).

公共类MyBenchmark{

@Benchmark
public void otherMethod() {
}

@Benchmark
public void sessionCreation() {
}

public static void main(String[] args) throws RunnerException {
    Options opt = new OptionsBuilder().include(MyBenchmark.class.getSimpleName()).forks(1).build();
    new Runner(opt).run();
}
运行到以下错误:

java.lang.NoSuchMethodError: tesco.finance.gss.generated.MyBenchmark_jmhType.testMethod()V
    at tesco.finance.gss.generated.MyBenchmark_testMethod_jmhTest.testMethod_thrpt_jmhStub(MyBenchmark_testMethod_jmhTest.java:119)
    at tesco.finance.gss.generated.MyBenchmark_testMethod_jmhTest.testMethod_Throughput(MyBenchmark_testMethod_jmhTest.java:83)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:453)
    at org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:437)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

解决方案是执行mvn清理安装,然后再次运行该程序。效果非常好!

解决方案是执行mvn清理安装,然后再次运行该程序。效果非常好!

感谢您收到类似的错误消息:
NoSuchMethodError:'void master.benchmark.generated.CompareBenchmark\u jmhType.setUpRandom()“
Thank收到了类似的错误消息:
NoSuchMethodError:“void master.benchmark.generated.CompareBenchmark_jmhType.setUpRandom()”