当前位置:网站首页>StopWatch
StopWatch
2022-04-21 19:58:00 【xixiyuguang】
public static void main(String[] args) {
Long startTime = System.currentTimeMillis();
// Your business code
Long endTime = System.currentTimeMillis();
Long elapsedTime = (endTime - startTime) / 1000;
System.out.println(" The total time of this segment :" + elapsedTime + "s");
}
public static void main(String[] args) throws InterruptedException {
StopWatch stopWatch = new StopWatch();
// Task the first mock exam 3 Second
stopWatch.start("TaskOneName");
Thread.sleep(1000 * 3);
System.out.println(" Current task name :" + stopWatch.currentTaskName());
stopWatch.stop();
// Task the first mock exam 10 Second
stopWatch.start("TaskTwoName");
Thread.sleep(1000 * 10);
System.out.println(" Current task name :" + stopWatch.currentTaskName());
stopWatch.stop();
// Task the first mock exam 10 Second
stopWatch.start("TaskThreeName");
Thread.sleep(1000 * 10);
System.out.println(" Current task name :" + stopWatch.currentTaskName());
stopWatch.stop();
// Printing time
System.out.println(stopWatch.prettyPrint());
System.out.println(stopWatch.shortSummary());
// stop After that, its value is null
System.out.println(stopWatch.currentTaskName());
// Information about the last task
System.out.println(stopWatch.getLastTaskName());
System.out.println(stopWatch.getLastTaskInfo());
// The total time of the task If you want to get the details of each task ( Including its task name 、 Time consuming, etc ) You can use
System.out.println(" All tasks take time :" + sw.getTotalTimeMillis());
System.out.println(" Total tasks :" + sw.getTaskCount());
System.out.println(" All task details :" + sw.getTaskInfo());
}
版权声明
本文为[xixiyuguang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211952089340.html
边栏推荐
- How to solve the thread safety problem without locking
- WLAN Qpower 介绍
- 什么是注解
- 05.原型模式
- 杰理之使用硬件定时器来模拟中断请求【篇】
- Publicity of the winners of the 9th "Datang Cup" National College Students' mobile communication 5g technology competition
- 杰理之系统内核电压【篇】
- MySQL 2003 can't connect to MySQL server on 'localhost' (10038)
- 824. Goat Latin
- URL to download network resources
猜你喜欢

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

How to solve the thread safety problem without locking

Digital business cloud community property platform system solution - easy property management and leveraging potential business opportunities

Why does SVPWM module have sector judgment error?

int count= cmd. ExecuteNonQuery(); There is a syntax error nearby

In 2023, Nankai University took the postgraduate entrance examination for the master of Taxation and went ashore. Experience and guidance of predecessors in preparing for the examination

MySQL 2003 can't connect to MySQL server on 'localhost' (10038)

Meaning of stripe in image

知道创宇发布重磅战略方案,构建持续交火的实战化防御体系

联想公布ESG新进展:承诺2025年全线计算机产品100%含有再生塑料
随机推荐
mui选项卡怎么实现循环轮播
Interface component telerik UI for WPF Getting Started Guide - color theme generator
Gbase 8A set group_ concat_ max_ Solution to error reporting after len parameter
杰理之复位IO维持电平使用说明【篇】
ParaView Glance 启动报错
【2021】腾讯秋招技术岗编程 有效序列的数量
新冠无情人间有情,欣隆农业保民生共抗疫——慰问抗疫一线及爱老助困送欣隆酵醒鸡蛋蔬菜进社区公益行动
第九届”大唐杯“全国大学生移动通信5G技术大赛省赛获奖名单公示
PostgreSql postgres_ fdw
register关键字的使用
QT 6.2.4 package of Conan package manager
How to solve the thread safety problem without locking
码出高效 第七章 并发与多线程
1075 PAT Judge (25 分)
SAP MTS/MTO/ETO专题之七:Q+M模式前后台操作
Mysql错误2005
MySQL之2003-Can‘t connect to MySQL server on ‘localhost‘(10038)的解决办法
Modifying the root password of MySQL
Create thread pool manually
【时序】LSTNet:结合 CNN、RNN 以及 AR 的时间序列预测模型