"Apache Commons Lang" Stopwatch Task Execution Time Monitor

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.