public void test() throws InterruptedException {
org.springframework.util.StopWatch stopWatch = new org.springframework.util.StopWatch();
stopWatch.start("任务1");
System.out.println("开始任务1");
Thread.sleep(1000 * 3);
System.out.println("结束任务1");
stopWatch.stop();
stopWatch.start("任务2");
System.out.println("开始任务2");
Thread.sleep(1000 * 3);
System.out.println("结束任务2");
stopWatch.stop();
stopWatch.start("任务3");
System.out.println("开始任务3");
Thread.sleep(1000 * 3);
System.out.println("结束任务3");
stopWatch.stop();
System.out.println("总任务数:" + stopWatch.getTaskCount());
System.out.println("总耗时:" + stopWatch.getTotalTimeMillis());
System.out.println("每个任务具体信息:" + JSONArray.toJSONString(stopWatch.getTaskInfo()));
}```
计算进程花费时间
最新推荐文章于 2024-03-18 14:19:48 发布