当前位置:网站首页>用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
边栏推荐
- Three. JS learning - light and shadow (understanding)
- Postman manage test cases
- Cve-2019-11043 (PHP Remote Code Execution Vulnerability)
- RTP GB28181 文件测试工具
- 最高法院,离婚案件判决标准
- Summary of three log knowledge points of MySQL
- Upload nestjs configuration files, configure the use of middleware and pipelines
- Summary of redis basic knowledge points
- 关于Unity Inspector上的一些常用技巧,一般用于编辑器扩展或者其他
- 2021 robocom world robot developer competition - undergraduate group (semi-finals)
猜你喜欢
Crazy God said redis notes
[lgr-109] Luogu may race II & windy round 6
Principle and performance analysis of lepton lossless compression
GAMES202-WebGL中shader的编译和连接(了解向)
The underlying structure of five data types in redis
RT thread analysis - object container implementation and function
GAMES202-WebGL中shader的編譯和連接(了解向)
Fuzzy -- basic application method of AFL
行业专网对比公网,优势在哪儿?能满足什么特定要求?
Why does MySQL need two-phase commit
随机推荐
L'introduction en bourse de MSK Electronics a pris fin: 800 millions de RMB d'actifs de Henan étaient des actionnaires
2021 robocom world robot developer competition - undergraduate group (semi-finals)
饼干(考试版)
Distributed transaction solution
[lgr-109] Luogu may race II & windy round 6
The web project imported the MySQL driver jar package but failed to load it into the driver
acwing周赛58
组播和广播的知识点梳理
nacos-高可用seata之TC搭建(02)
Crazy God said redis notes
Postman pre script - global variables and environment variables
Excellent PM must experience these three levels of transformation!
JS quick start (II)
What should the project manager do if there is something wrong with team collaboration?
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Some common skills on unity inspector are generally used for editor extension or others
比尔·盖茨晒18岁个人简历,48年前期望年薪1.2万美元
The video in win10 computer system does not display thumbnails
ISP学习(2)
DMA use of stm32