2

例如,我想知道我的测试中不同部分的执行时间是什么时候

@Test
public void HappyPathTest() {

        connectToServiceRemote();
        // take execution time of connectToServiceRemote();
        getData();
        // take execution time of getData()
        transformData();
        // take execution time of transformData()

}

我目前所做的是使用丑陋 System.currentTimeMillis()并将结果打印到标准输出。

我的问题是:

  • junit 框架中是否有比使用System.currentTimeMillis().
  • 如果没有,我如何System.currentTimeMillis()在junit的结果报告中包含计算的信息。
4

1 回答 1

1

库可用于性能测量: http: //labs.carrotsearch.com/junit-benchmarks.html

于 2013-11-11T10:50:27.063 回答