当前位置:网站首页>用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
边栏推荐
- acwing周赛58
- 麥斯克電子IPO被終止:曾擬募資8億 河南資產是股東
- 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
- A little knowledge of CPU, disk and memory
- The underlying structure of five data types in redis
- Bubble sort
- 关于es8316的音频爆破音的解决
- 驱动开发——HelloWDM驱动
- Hyperledger Fabric2. Some basic concepts of X (1)
- Oracle query table index, unique constraint, field
猜你喜欢
idea一键导包
Postman Association
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
MPLS experiment
Postman关联
二叉树基本知识和例题
A blog to achieve embedded entry
Cve-2019-11043 (PHP Remote Code Execution Vulnerability)
Golang -- TCP implements concurrency (server and client)
IPv6 comprehensive experiment
随机推荐
Hometown 20 years later (primary school exercises)
Chip debugging of es8316 of imx8mp
Orm-f & Q object
acwing周赛58
Postman Association
The video in win10 computer system does not display thumbnails
Cve-2019-11043 (PHP Remote Code Execution Vulnerability)
Leetcode dynamic planning day 16
Finance online homework
GAMES202-WebGL中shader的编译和连接(了解向)
Crazy God said redis notes
F12 solve the problem that web pages cannot be copied
Summary of three log knowledge points of MySQL
Luogu deep foundation part 1 Introduction to language Chapter 2 sequential structure programming
MySQL time processing
CUDA11.1在线安装
RT thread analysis - object container implementation and function
[FreeRTOS interrupt experiment]
关于es8316的音频爆破音的解决
Mongodb basic knowledge summary