Stopwath is a task execution time monitor under the Apache Commons lang package
Main methods:
Start (); Start timing
Split (); Set Split point
Getsplittime (); Gets the time from start to the last split
Reset (); Reset Timings
Suspend (); Pause the timer until resume () is called
Resume (); Recovery Timings
Stop (); Stop timing
GetTime (); Counting the timings from start to present
Code:
Import Org.apache.commons.lang3.time.stopwatch;public class Stopwatchtest {public static void main (string[] args) Throws Interruptedexception {StopWatch watch = new StopWatch (); Watch.start ();//statistics from start to experience the time Thread.Sleep (1000); System.out.println (Watch.gettime ());//Statistical Timing point Thread.Sleep (+); Watch.split (); System.out.println (Watch.getsplittime ());//Statistical Timing point Thread.Sleep (+); Watch.split (); System.out.println (Watch.getsplittime ());//reset, re-timer watch.reset (); Watch.start (); Thread.Sleep (1000); System.out.println (Watch.gettime ());//pause and resume watch.suspend (); System.out.println ("Pause for 2 Seconds"); Thread.Sleep (+); Watch.resume (); Thread.Sleep (+); Watch.stop (); System.out.println (Watch.gettime ());}}
This article is from the architect's path blog, so be sure to keep this source http://lizhuquan0769.blog.51cto.com/2591147/1785507
"Apache Commons Lang" Stopwatch Task Execution Time Monitor