com.netflix.servo.monitor
Class BasicStopwatch

java.lang.Object
  extended by com.netflix.servo.monitor.BasicStopwatch
All Implemented Interfaces:
Stopwatch
Direct Known Subclasses:
TimedStopwatch

public class BasicStopwatch
extends java.lang.Object
implements Stopwatch

This class does not enforce starting or stopping once and only once without a reset.


Constructor Summary
BasicStopwatch()
          Create a new stopwatch with no associated timer.
 
Method Summary
 long getDuration()
          Returns the duration in nanoseconds.
 long getDuration(java.util.concurrent.TimeUnit timeUnit)
          Returns the duration in the specified time unit.
 void reset()
          Reset the stopwatch so that it can be used again.
 void start()
          Mark the start time.
 void stop()
          Mark the end time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicStopwatch

public BasicStopwatch()
Create a new stopwatch with no associated timer.

Method Detail

start

public void start()
Mark the start time.

Specified by:
start in interface Stopwatch

stop

public void stop()
Mark the end time.

Specified by:
stop in interface Stopwatch

reset

public void reset()
Reset the stopwatch so that it can be used again.

Specified by:
reset in interface Stopwatch

getDuration

public long getDuration(java.util.concurrent.TimeUnit timeUnit)
Returns the duration in the specified time unit.

Specified by:
getDuration in interface Stopwatch

getDuration

public long getDuration()
Returns the duration in nanoseconds. No checks are performed to ensure that the stopwatch has been properly started and stopped before executing this method. If called before stop it will return the current duration.

Specified by:
getDuration in interface Stopwatch