当前位置:网站首页>用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
边栏推荐
- Excellent PM must experience these three levels of transformation!
- DMA use of stm32
- RTP gb28181 document testing tool
- 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
- 程序员在互联网行业的地位 | 每日趣闻
- Hometown 20 years later (primary school exercises)
- The kernel determines whether peripherals are attached to the I2C address
- A little knowledge of CPU, disk and memory
- Rce code and Command Execution Vulnerability
- Quick sort
猜你喜欢
随机推荐
Compilation et connexion de shader dans games202 - webgl (comprendre la direction)
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
On the solution of es8316's audio burst
nacos-高可用seata之TC搭建(02)
Oracle deletes duplicate data, leaving only one
Summary of redis basic knowledge points
比尔·盖茨晒18岁个人简历,48年前期望年薪1.2万美元
GAMES202-WebGL中shader的编译和连接(了解向)
行业专网对比公网,优势在哪儿?能满足什么特定要求?
Collection + interview questions
Mongodb basic knowledge summary
Introduction of several RS485 isolated communication schemes
图论的扩展
驱动开发——第一个HelloDDK
[数学建模] 微分方程--捕鱼业的持续发展
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
Distributed transaction solution
RTP gb28181 document testing tool
Oracle query table index, unique constraint, field
February 12 relativelayout









