下面列出了怎么用org.junit.rules.Stopwatch的API类实例代码及写法,或者点击链接到github查看源代码。
public static ResultMatcher executionTimeLessThan(Stopwatch stopwatch, long expectedTimeMs) {
return mvcResult -> {
long time = stopwatch.runtime(TimeUnit.MILLISECONDS);
System.out.println("Execution time: " + time + "ms");
assertThat(time).isLessThanOrEqualTo(expectedTimeMs);
};
}