通常的时间监控方式
//方法运行开始
long start = System.currentTimeMillis();
do.something();
long end = System.currentTimeMillis();
log.info("某业务的耗时:" + start-end);
stopWatch方式
StopWatch sw = new StopWatch("test");
sw.start("task1");
do.something();
sw.stop();
sw.start("task2");
do.something();
sw.stop();
System.out.println(sw.prettyPrint());
//运行结果
-----------------------------------------
ms % Task name
-----------------------------------------
00948 100% task1
-----------------------------------------
ms % Task name
-----------------------------------------
00948 100% task2