监听耗时-StopWatch
// Spring的StopWatch
// 但其实如果自己封装的话,可以做得更简洁一点;
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);