public class OpTimer extends Object
Constructor and Description |
---|
OpTimer()
Create an OpTimer instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isRunning()
Returns timer running state
|
long |
now()
Returns current timer elapsed time as nanoseconds.
|
long |
now(TimeUnit timeUnit)
Converts current timer value to specific unit.
|
OpTimer |
reset()
Stops timer instance and current elapsed time to 0.
|
double |
scale(TimeUnit timeUnit)
Returns the current elapsed time scaled to the provided time unit.
|
OpTimer |
start()
Start the timer instance.
|
OpTimer |
stop()
Stop the timer instance.
|
String |
toString()
Return the current elapsed time in nanoseconds as a string.
|
public boolean isRunning()
public OpTimer start() throws IllegalStateException
IllegalStateException
- if start is called on running instance.public OpTimer stop() throws IllegalStateException
IllegalStateException
- if stop is called on instance that is not running.public OpTimer reset()
public long now(TimeUnit timeUnit)
timeUnit
- the time unit that will converted to.public double scale(TimeUnit timeUnit)
now(TimeUnit)
but returns the value as a double.
Note: this method is not included in the hadoop 2.7 org.apache.hadoop.util.StopWatch class. If that class is adopted, then provisions will be required to replace this method.
timeUnit
- the time unit to scale the elapsed time to.public long now()
Copyright © 2011–2018 The Apache Software Foundation. All rights reserved.