org.apache.commons.monitoring
Interface StopWatch

All Known Implementing Classes:
DefaultStopWatch, ExecutionStopWatch

public interface StopWatch

Author:
Nicolas De Loof

Method Summary
 void cancel()
          Cancel monitoring.
 long getElapsedTime()
           
 Monitor getMonitor()
           
 boolean isPaused()
           
 boolean isStoped()
           
 void pause()
          Temporary stop the StopWatch.
 void resume()
          Resume the StopWatch after a pause.
 void stop()
          Stop monitoring the process.
 void stop(boolean canceled)
          Convenience method to stop or cancel a Stopwatch depending on success of monitored operation
 

Method Detail

getElapsedTime

long getElapsedTime()
Returns:
Elapsed time (in nanoseconds) for the monitored process, not including paused time

pause

void pause()
Temporary stop the StopWatch. Elapsed time calculation will not include time spent in paused mode.


resume

void resume()
Resume the StopWatch after a pause.


stop

void stop()
Stop monitoring the process. A StopWatch created with #start(Monitor) cannot be re-used after stopped has been called.


stop

void stop(boolean canceled)
Convenience method to stop or cancel a Stopwatch depending on success of monitored operation

Parameters:
canceled -

cancel

void cancel()
Cancel monitoring. Elapsed time will not be computed and will not be published to the monitor.

In some circumstances you want to monitor time elapsed from early stage of computation, and discover latter if the computed data is relevant. For example, monitoring a messaging system, but beeing interested only by some types of messages. In such case, a StopWatch can be started early and canceled when the application is able to determine it's relevancy.

In any way, the probe will still report thread concurrency even if canceled.


isStoped

boolean isStoped()
Returns:
true if the StopWatch has been stopped

isPaused

boolean isPaused()
Returns:
true if the StopWatch has been paused

getMonitor

Monitor getMonitor()


Copyright © 2008 The Apache Software Foundation. All Rights Reserved.