Commit d0fc1a35 by gechengyang

提交StopWatchTest测试类

parent bb7fe6b7
package com.ceb.gjjs.mda.junitTest;
import org.junit.jupiter.api.Test;
import org.springframework.util.StopWatch;
public class StopWatchTest {
@Test
public void test()
{
StopWatch stopWatch = new StopWatch("test1");
stopWatch.start("任务1");
method1();
stopWatch.stop();
stopWatch.start("任务2");
method2();
stopWatch.stop();
System.out.println("totalTime="+stopWatch.getTotalTimeMillis());
System.out.println("print="+stopWatch.prettyPrint());
}
public void method1()
{
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
public void method2()
{
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment