Package org.apache.hadoop.util
Class StopWatch
java.lang.Object
org.apache.hadoop.util.StopWatch
- All Implemented Interfaces:
Closeable,AutoCloseable
A simplified StopWatch implementation which can measure times in nanoseconds.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanThe method is used to find out if the StopWatch is started.longnow()longnow.reset()Reset elapsed time to zero and make the state of stopwatch stop.start()Start to measure times and make the state of stopwatch running.stop()Stop elapsed time and make the state of stopwatch stop.toString()
-
Constructor Details
-
StopWatch
public StopWatch() -
StopWatch
Used for tests to be able to create a StopWatch which does not follow real time.- Parameters:
timer- The timer to base this StopWatch's timekeeping off of.
-
-
Method Details
-
isRunning
public boolean isRunning()The method is used to find out if the StopWatch is started.- Returns:
- boolean If the StopWatch is started.
-
start
Start to measure times and make the state of stopwatch running.- Returns:
- this instance of StopWatch.
-
stop
Stop elapsed time and make the state of stopwatch stop.- Returns:
- this instance of StopWatch.
-
reset
Reset elapsed time to zero and make the state of stopwatch stop.- Returns:
- this instance of StopWatch.
-
now
now.- Parameters:
timeUnit- timeUnit.- Returns:
- current elapsed time in specified timeunit.
-
now
public long now()- Returns:
- current elapsed time in nanosecond.
-
toString
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-