監(jiān)聽耗時(shí)-StopWatch
// Spring的StopWatch
// 但其實(shí)如果自己封裝的話捞蚂,可以做得更簡(jiǎn)潔一點(diǎn)霍骄;
StopWatch stopWatch = new StopWatch();
stopWatch.start("task1");
Thread.sleep(1000L);
stopWatch.stop();
long task1Cost = stopWatch.getLastTaskTimeMillis();
stopWatch.start("task2");
Thread.sleep(1000L);
stopWatch.stop();
long task2Cost = stopWatch.getLastTaskTimeMillis();
long totalCost = stopWatch.getTotalTimeMillis();
System.out.println("task1Cost:" + task1Cost + ",task2Cost:" + task2Cost + ",totalCost:" + totalCost);
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者