我正在尝试将卡尺代码包装在 junit 中,以便性能测试作为我的单元测试的一部分运行。它似乎工作 - 卡尺测试实际上运行,但它没有成功退出。设置这些东西的正确方法是什么?
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);
}
}