StopWatch sw = new StopWatch();
sw.start("任意取名1");
要计算的操作代码1
sw.stop();
System.out.println(sw.prettyPrint());
其余代码
sw.start("任意取名2");
要计算的操作代码2
sw.stop();
System.out.println(sw.prettyPrint());
计算时间为每个start到stop,第一个输出结果为代码1的时间,第二个输出结果为代码1和2的时间之和,console控制台能看到每个运行的时间。也可以log.info(sw.prettyPrint())日志来打印