본문 바로가기

Java/Spring

Spring StopWatch

StopWatch stopWatch = new StopWatch("id");

stopWatch.start("taskName1");
task1();
stopWatch.stop();

stopWatch.start("taskName2");
task2();
stopWatch.stop();

stopWatch.getTotalTimeMillis(); // 전체 작업시간
stopWatch.prettyPrint();
// StopWatch 'id': running time (millis) = 2000
// -----------------------------------------
// ms     %     Task name
// -----------------------------------------
// 01000  050%  taskName1
// 01000  050%  taskName2