当前位置:网站首页>StopWatch
StopWatch
2022-04-21 19:52:00 【xixiyuguang】
public static void main(String[] args) {
Long startTime = System.currentTimeMillis();
// 你的业务代码
Long endTime = System.currentTimeMillis();
Long elapsedTime = (endTime - startTime) / 1000;
System.out.println("该段总共耗时:" + elapsedTime + "s");
}
public static void main(String[] args) throws InterruptedException {
StopWatch stopWatch = new StopWatch();
// 任务一模拟休眠3秒钟
stopWatch.start("TaskOneName");
Thread.sleep(1000 * 3);
System.out.println("当前任务名称:" + stopWatch.currentTaskName());
stopWatch.stop();
// 任务一模拟休眠10秒钟
stopWatch.start("TaskTwoName");
Thread.sleep(1000 * 10);
System.out.println("当前任务名称:" + stopWatch.currentTaskName());
stopWatch.stop();
// 任务一模拟休眠10秒钟
stopWatch.start("TaskThreeName");
Thread.sleep(1000 * 10);
System.out.println("当前任务名称:" + stopWatch.currentTaskName());
stopWatch.stop();
// 打印出耗时
System.out.println(stopWatch.prettyPrint());
System.out.println(stopWatch.shortSummary());
// stop后它的值为null
System.out.println(stopWatch.currentTaskName());
// 最后一个任务的相关信息
System.out.println(stopWatch.getLastTaskName());
System.out.println(stopWatch.getLastTaskInfo());
// 任务总的耗时 如果你想获取到每个任务详情(包括它的任务名、耗时等等)可使用
System.out.println("所有任务总耗时:" + sw.getTotalTimeMillis());
System.out.println("任务总数:" + sw.getTaskCount());
System.out.println("所有任务详情:" + sw.getTaskInfo());
}
版权声明
本文为[xixiyuguang]所创,转载请带上原文链接,感谢
https://blog.csdn.net/xixiyuguang/article/details/124325935
边栏推荐
- 界面组件Telerik UI for WPF入门指南 - 颜色主题生成器
- Solutions informatiques pour les entreprises manufacturières haut de gamme, maintenance prédictive de l'équipement, des données et du système de la plate - forme de commerce électronique industriel
- 小程序项目文件介绍
- 05. Prototype mode
- Unity Socket
- PMP考试这些答题思路,你都掌握了吗?
- If the application is closed gracefully according to the integrated actor
- [maximum value of jz47 gift]
- 杰理之使用硬件定时器来模拟中断请求【篇】
- Dolphin DB vscode plug-in tutorial
猜你喜欢

int count= cmd.ExecuteNonQuery();附近有一条语法错误

新冠无情人间有情,欣隆农业保民生共抗疫——慰问抗疫一线及爱老助困送欣隆酵醒鸡蛋蔬菜进社区公益行动

Comprehensive solution for digital construction of double prevention mechanism in hazardous chemical enterprises

SAP MTS / MTO / ETO topic 7: front and rear operation in Q + M mode

企业跨境电商平台服务解决方案,跨境电子商务贸易业务框架搭建运维
![[netty] is it difficult to implement a redis client by yourself?](/img/02/a9609465d2cc90251168b2ed0b94f0.png)
[netty] is it difficult to implement a redis client by yourself?

一键安装ROS和rosdep(NO 墙)
![Leetcode goat Latin [analog string] the way of leetcode in heroding](/img/da/3761b46aec6a56f2f30e0fd91c7f42.png)
Leetcode goat Latin [analog string] the way of leetcode in heroding

Mysql错误2005

照片删除了怎么恢复?4个方案,这才是官方指南
随机推荐
Mysql错误2005
什么是注解
OpenCV之OpenCL介绍
Unity Socket
int count= cmd.ExecuteNonQuery();附近有一条语法错误
LeetCode 山羊拉丁文[模拟 字符串] HERODING的LeetCode之路
知识点合集
配置PyTorch、TensorFlow 环境
牛客BM40. 重建二叉树
学历造假、考试包过……考证市场有多乱
redis
824. Goat Latin
使用CMake构建/Qt 5和Qt 6兼容性
Introduction to OpenCL of opencv
2022下半年PMP考试开始报名,须知
Digital business cloud community property platform system solution - easy property management and leveraging potential business opportunities
多因子策略
Redis基础
80.(leaflet篇)leaflet调用geoserver发布的postgis数据图层
Redis installation and configuration startup