- spring 提供 stopWatch 来进行统计耗时
package com.kuangsheng.test;
import org.springframework.util.StopWatch;
/** 统计耗时
* spring 提供 stopWatch 来进行统计耗时
* */
public class TestMain {
public static void main(String[] args) throws InterruptedException {
StopWatch sw = new StopWatch("spring 耗时工具");
sw.start("开始任务");
Thread.sleep(2000);
sw.stop();
System.out.println("输出耗时:"+sw.getLastTaskTimeMillis());
System.out.println("输出名字:"+sw.getLastTaskName());
}
}