当我尝试使用Caliper运行基准方法时,它会在完成任何测量之前退出。我在调试器中确认 Caliper 正在执行基准测试方法两次,当时它正在经历其试运行阶段。但是当它试图运行实验时,它在完成任何事情之前就退出了。
基准测试方法非常简单(虽然它调用了很多其他应用程序代码):
@Benchmark
public int testNewOrder(int reps) {
OrderRequest newOrder = this.newOrder;
for (int i = 0; i < reps; i++) {
router.getWorker().processOrderRequest(USER_CONN_ID, newOrder, System.currentTimeMillis());
mockFixEngineManager.clear();
}
return 10;
}
运行 with--verbose
不会产生我可以看到的任何不同的输出。整个输出是:
Experiment selection:
Instruments: [allocation, runtime]
User parameters: {}
Virtual machines: [default]
Selection type: Full cartesian product
This selection yields 2 experiments.
Starting experiment 1 of 2: {instrument=allocation, benchmarkMethod=testNewOrder, vm=default, parameters={}}… The worker exited without producing data. It has likely crashed. Run with --verbose to see any worker output.
我在 Windows 7 上运行,使用 JDK 1.7.0_40(以防万一)。我通过调试器运行 Caliper 代码,我看到它在这里退出:
// ExperimentingCaliperRun.java, line 384
processFuture.addListener(new Runnable() {
@Override public void run() {
if (!pipeReaderFuture.isDone()) {
// the process completed without the pipe ever being written to. it crashed.
// TODO(gak): get the output from the worker so we can know why it crashed
stdout.print("The worker exited without producing data. "
+ "It has likely crashed. Run with --verbose to see any worker output.\n");
stdout.flush();
System.exit(1);
}
}
}, MoreExecutors.sameThreadExecutor());
pipeReaderFuture.isDone()
返回假。我不确定为什么。没有写入 stderr 的错误。