[英]Junit setup with caliper
I am trying to wrap the caliper code in junit so the performance tests run as part of my unit tests. 我试图在junit中包装caliper代码,以便性能测试作为我的单元测试的一部分运行。 It seems to work - the caliper test actually runs, but it doesn't exit successfully.
它似乎工作 - 卡尺测试实际运行,但它没有成功退出。 What's the proper way to set this stuff up?
设置这个东西的正确方法是什么?
import static org.junit.Assert.*;
import org.junit.Test;
import com.google.caliper.Runner;
import com.google.caliper.SimpleBenchmark;
public class CaliperBenchmarkExample extends SimpleBenchmark {
public void timeNanoTime(int reps) {
for (int i = 0; i < reps; i++) {
System.nanoTime();
}
}
@Test
public void testPerformance() {
Runner.main(CaliperBenchmarkExample.class, new String[] { });
assertTrue(true);
}
}
There's no mechanism to run Caliper tests as JUnit tests. 没有机制可以像JUnit测试那样运行Caliper测试。 Doing so is complicated because of the way that Caliper forks a child process to isolate your benchmarks.
这样做很复杂,因为Caliper要求子进程隔离您的基准测试。 And Caliper benchmarks tend to run for several seconds which may harm test performance.
Caliper基准测试往往会运行几秒钟,这可能会损害测试性能。
You may want to investigate caliper-ci , an open source project that runs Caliper benchmarks continuously. 您可能想要研究caliper-ci ,这是一个持续运行Caliper基准测试的开源项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.