import org.springframework.util.StopWatch;
public static void main(String[] args) throws InterruptedException {
StopWatch sw = new StopWatch("模板测试");
sw.start("任务1");
Thread.sleep(1000 * 1);
sw.stop();
sw.start("任务2");
Thread.sleep(1000 * 2);
sw.stop();
sw.start("任务3");
Thread.sleep(1000 * 3);
sw.stop();
//打印各子任务耗时比例
System.out.println(sw.prettyPrint());
System.out.println("所有任务总耗时:" + sw.getTotalTimeMillis() + "ms");
}
java stopwatch 使用
最新推荐文章于 2025-03-26 10:28:36 发布