package com.newlandframework.test;
import org.springframework.util.StopWatch;
/**
* @Package: com.newlandframework.test
* @Description: ${todo}
* @author: liuxin
* @date: 2017/8/22 下午7:03
*/
public class Main {
/*
-----------------------------------------
ms % Task name
-----------------------------------------
00103 045% 读取文件
00104 046% 文件删除
00011 005% 文件拷贝
00010 004% 文件结束*/
/**
* 每个执行任务,占用总共时间的比例
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
org.springframework.util.StopWatch sw = new StopWatch();
sw.start("读取文件");
Thread.sleep(100);
sw.stop();
sw.start("文件删除");
Thread.sleep(100);
sw.stop();
sw.start("文件拷贝");
Thread.sleep(10);
sw.stop();
sw.start("文件结束");
Thread.sleep(10);
sw.stop();
System.out.println(sw.prettyPrint());
long stime = System.currentTimeMillis();
Thread.sleep(1000);
long etime = System.currentTimeMillis();
System.out.println("执行时间:" + (etime - stime));
}
}
StopWatch工具类统计时间
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 干货要点: 1、叙述、描写和说明是三种记“实”的能力。 2、议论和抒情是两种写“虚”的能力。 3、根据表达的中心,...