StopWatch工具类

xiaoxiao2021-02-28  86

package com.ceair.pss; import org.springframework.util.StopWatch; public class StopWatchTest { public static void main(String[] args) throws InterruptedException { StopWatch stopWatch = new StopWatch("查询航班动态"); stopWatch.start("任务一"); Thread.sleep(1000); stopWatch.stop(); stopWatch.start("任务二"); Thread.sleep(2000); stopWatch.stop(); stopWatch.start("任务三"); Thread.sleep(3000); stopWatch.stop(); System.out.println(stopWatch.getLastTaskName() + "用时:" + stopWatch.getLastTaskTimeMillis()); System.out.println(stopWatch.prettyPrint()); } }

输出:

任务三用时:3000 StopWatch '查询航班动态': running time (millis) = 6001 ----------------------------------------- ms % Task name ----------------------------------------- 01000 017% 任务一 02001 033% 任务二 03000 050% 任务三

转载请注明原文地址: https://www.6miu.com/read-73149.html

最新回复(0)