当前位置:   article > 正文

Stopwatch用法_stopwatch stopwatch = new stopwatch();

stopwatch stopwatch = new stopwatch();

总计时

计时
StopWatch stopWatch = new StopWatch();
stopWatch.start();                                //计时开始
// do something
 Thread.sleep(100);
stopWatch.stop();                                  //计时结束
stopWatch.getTotalTimeMillis()                     //总用时

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

分段计时

StopWatch sw = new StopWatch("test");
   sw.start("task1");
    // do something
   Thread.sleep(100);
   sw.stop();
   sw.start("task2");
   // do something
   Thread.sleep(200);
   sw.stop();
   System.out.println(sw.prettyPrint());
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/511901
推荐阅读
相关标签
  

闽ICP备14008679号