import org.springframework.util.StopWatch;
public static void main(String[] args) throws InterruptedException {
StopWatch sw = new StopWatch("测试计时工具类StopWatch");
sw.start("第一次计时");
Thread.sleep(100);
sw.stop();
sw.start("第二次计时");
Thread.sleep(200);
sw.stop();
System.out.println(sw.prettyPrint());
}
次のように出力される:
ストップウォッチ「テストタイミングツールストップウォッチ」:実行時間(ミリ秒) = 302
ミズ | % | タスク名 |
---|---|---|
00101 | 033パーセント | 最初のタイマー |
00201 | 067パーセント | 第2のタイミング |