私はキャリパーを初めて使用します。メイン メソッドを作成し、IntelliJ を使用して右クリックして [実行] を選択できるかどうかを知りたいですか?
public class Benchmark1 extends Benchmark{
@Param({"10", "100", "1000", "10000"}) private int length;
public void timeNanoTime(int reps) {
for (int i = 0; i < reps; i++) {
System.nanoTime();
}
}
public static void main(String[] args) {
CaliperMain.main(Benchmark1.class, args);
}
}
上記を実行しようとすると、次のエラーが発生します。
Experiment selection:
Instruments: [allocation, micro]
User parameters: {length=[10, 100, 1000, 10000]}
Virtual machines: [default]
Selection type: Full cartesian product
This selection yields 8 experiments.
Starting experiment 1 of 8: {instrument=allocation, method=NanoTime, vm=default, parameters={length=10}}
java.lang.RuntimeException: java.lang.NoSuchMethodError: com.google.common.base.Stopwatch.elapsed(Ljava/util/concurrent/TimeUnit;)J
at com.google.caliper.runner.ExperimentingCaliperRun.measure(ExperimentingCaliperRun.java:394)
at com.google.caliper.runner.ExperimentingCaliperRun.run(ExperimentingCaliperRun.java:207)
at com.google.caliper.runner.CaliperMain.exitlessMain(CaliperMain.java:131)
at com.google.caliper.runner.CaliperMain.main(CaliperMain.java:78)
at com.google.caliper.runner.CaliperMain.main(CaliperMain.java:66)
at xxxxxxxxxxx(redacted).main(Benchmark1.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.NoSuchMethodError: com.google.common.base.Stopwatch.elapsed(Ljava/util/concurrent/TimeUnit;)J
at com.google.caliper.runner.ExperimentingCaliperRun.getRemainingTrialNanos(ExperimentingCaliperRun.java:406)
at com.google.caliper.runner.ExperimentingCaliperRun.access$400(ExperimentingCaliperRun.java:95)
at com.google.caliper.runner.ExperimentingCaliperRun$LineConsumer.call(ExperimentingCaliperRun.java:513)
at com.google.caliper.runner.ExperimentingCaliperRun$LineConsumer.call(ExperimentingCaliperRun.java:495)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:680)
The worker exited without producing data. It has likely crashed. Run with --verbose to see any worker output.
An unexpected exception has been thrown by the caliper runner.
Please see https://sites.google.com/site/caliperusers/issues
Process finished with exit code 1
また、IntelliJ を使用しているため、キャリパーは maven のように定義されています (つまり、テスト スコープ)。
<dependency>
<groupId>com.google.caliper</groupId>
<artifactId>caliper</artifactId>
<version>${caliper-version}</version>
<scope>test</scope>
</dependency>
コマンドラインからキャリパーを実行するにはどうすればよいですか?