当前位置:网站首页>用StopWatch 统计代码耗时
用StopWatch 统计代码耗时
2022-07-06 05:01:00 【CBeann】
统计输出总耗时
StopWatch sw = new StopWatch();
sw.start();
// long task simulation
try {
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
}
sw.stop();
System.out.println(sw.getTotalTimeMillis());
以优雅的格式打出所有任务的耗时以及占比
StopWatch sw = new StopWatch();
sw.start("A");
Thread.sleep(500);
sw.stop();
sw.start("B");
Thread.sleep(300);
sw.stop();
sw.start("C");
Thread.sleep(200);
sw.stop();
System.out.println(sw.prettyPrint());
参考
https://mp.weixin.qq.com/s/RNsuFaONmruEnyJGKad5sA
边栏推荐
- Drive development - the first helloddk
- Nacos TC setup of highly available Seata (02)
- Raspberry pie 3.5-inch white screen display connection
- 关于Unity Inspector上的一些常用技巧,一般用于编辑器扩展或者其他
- The web project imported the MySQL driver jar package but failed to load it into the driver
- Quelques conseils communs sur l'inspecteur de l'unit é, généralement pour les extensions d'éditeur ou d'autres
- Pagoda configuration mongodb
- [NOIP2009 普及组] 分数线划定
- 二叉树基本知识和例题
- Redis has four methods for checking big keys, which are necessary for optimization
猜你喜欢
随机推荐
idea一键导包
Postman管理测试用例
Distributed transaction solution
Pagoda configuration mongodb
CUDA11.1在线安装
Cve-2019-11043 (PHP Remote Code Execution Vulnerability)
Oracle deletes duplicate data, leaving only one
Leetcode dynamic planning day 16
Chip debugging of es8316 of imx8mp
Microblogging hot search stock selection strategy
Oracle query table index, unique constraint, field
The underlying structure of five data types in redis
GAMES202-WebGL中shader的編譯和連接(了解向)
JS quick start (II)
驱动开发——HelloWDM驱动
Extension of graph theory
内核判断i2c地址上是否挂载外设
The web project imported the MySQL driver jar package but failed to load it into the driver
Review of double pointer problems
GAMES202-WebGL中shader的编译和连接(了解向)