有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

仅运行testMethod()的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()).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)

共 (1) 个答案

  1. # 1 楼答案

    解决方案是进行mvn清洁安装,然后再次运行该程序。工作得很有魅力