public class T1 {
@Test
void test01(){
long startTime = System.currentTimeMillis();
log.info("方法1开始执行,开始时间:{}",startTime);
method01();
long endTime = System.currentTimeMillis();
log.info("方法1执行结束,结束时间:{}",endTime);
log.info("方法1执行耗时:{}毫秒",endTime-startTime);
}
@Test
void test02(){
StopWatch stopWatch = new StopWatch("test02");
stopWatch.start("method01");
method01();
stopWatch.stop();
stopWatch.start("method02");
method02();
stopWatch.stop();
log.info("执行耗时情况如下:{}",stopWatch.prettyPrint());
}
public void method01(){
for (int i = 0; i < 10; i++){
try{
Thread.sleep(100);
}catch(Exception e){
e.printStackTrace();
}
}
}
public void method02(){
for (int i = 0; i < 14; i++){
try{
Thread.sleep(100);
}catch(Exception e){
e.printStackTrace();
}
}
}
}
标签:info,各个,log,void,stopWatch,method01,写法,public,统计
From: https://www.cnblogs.com/dragon-proud-sky/p/18371488