- java.lang.Object
- 
- org.hsqldb.lib.StopWatch
 
- 
 public class StopWatch extends java.lang.ObjectProvides the programatic analog of a physical stop watch.The watch can be started, stopped and zeroed and can be queried for elapsed running time. The watch accumulates elapsed time over starts and stops such that only the time actually spent running is recorded. If the watch is zeroed, then the accumulated time is discarded and the watch starts again with zero accumulated time. Nanosecond support added by fredt@users - Since:
- 1.7.2
- Author:
- Campbell Burnet (campbell-burnet@users dot sourceforge.net)
 
- 
- 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description longcurrentElapsedNanos()Retrieves the accumulated nanoseconds this object has spent running since it was last started.java.lang.StringcurrentElapsedNanosToMessage(java.lang.String prefix)Retrieves prefix + " in " + elapsedTime() + " ns."longcurrentElapsedTime()Retrieves the accumulated milliseconds this object has spent running since it was last started.java.lang.StringcurrentElapsedTimeToMessage(java.lang.String prefix)Retrieves prefix + " in " + elapsedTime() + " ms."longelapsedNanos()Retrieves the accumulated nanoseconds this object has spent running since it was last zeroed.java.lang.StringelapsedNanosToMessage(java.lang.String prefix)Retrieves prefix + " in " + elapsedNanos() + " ns."longelapsedTime()Retrieves the accumulated milliseconds this object has spent running since it was last zeroed.java.lang.StringelapsedTimeToMessage(java.lang.String prefix)Retrieves prefix + " in " + elapsedTime() + " ms."voidmark()voidstart()Ensures that this object is in the running state.voidstop()Ensures that this object is in the stopped state.java.lang.StringtoString()Retrieves the internal state of this object, as a String.voidzero()Zeros accumulated running time and restarts this object.
 
- 
- 
- 
Method Detail- 
elapsedTimepublic long elapsedTime() Retrieves the accumulated milliseconds this object has spent running since it was last zeroed.- Returns:
- the accumulated milliseconds this object has spent running since it was last zeroed.
 
 - 
elapsedNanospublic long elapsedNanos() Retrieves the accumulated nanoseconds this object has spent running since it was last zeroed.- Returns:
- the accumulated nanoseconds this object has spent running since it was last zeroed.
 
 - 
currentElapsedTimepublic long currentElapsedTime() Retrieves the accumulated milliseconds this object has spent running since it was last started.- Returns:
- the accumulated milliseconds this object has spent running since it was last started.
 
 - 
currentElapsedNanospublic long currentElapsedNanos() Retrieves the accumulated nanoseconds this object has spent running since it was last started.- Returns:
- the accumulated nanoseconds this object has spent running since it was last started.
 
 - 
zeropublic void zero() Zeros accumulated running time and restarts this object.
 - 
startpublic void start() Ensures that this object is in the running state. If this object is not running, then the call has the effect of setting thestartTimeattribute to the current value of System.nanoTime() and setting therunningattribute totrue.
 - 
stoppublic void stop() Ensures that this object is in the stopped state. If this object is in the running state, then this has the effect of adding to thetotalattribute the elapsed time since the last transition from stopped to running state and sets therunningattribute to false. If this object is not in the running state, this call has no effect.
 - 
markpublic void mark() 
 - 
elapsedTimeToMessagepublic java.lang.String elapsedTimeToMessage(java.lang.String prefix) Retrieves prefix + " in " + elapsedTime() + " ms."- Parameters:
- prefix- The string to use as a prefix
- Returns:
- prefix + " in " + elapsedTime() + " ms."
 
 - 
elapsedNanosToMessagepublic java.lang.String elapsedNanosToMessage(java.lang.String prefix) Retrieves prefix + " in " + elapsedNanos() + " ns."- Parameters:
- prefix- The string to use as a prefix
- Returns:
- prefix + " in " + elapsedNanos() + " ns."
 
 - 
currentElapsedTimeToMessagepublic java.lang.String currentElapsedTimeToMessage(java.lang.String prefix) Retrieves prefix + " in " + elapsedTime() + " ms."- Parameters:
- prefix- The string to use as a prefix
- Returns:
- prefix + " in " + elapsedTime() + " ms."
 
 - 
currentElapsedNanosToMessagepublic java.lang.String currentElapsedNanosToMessage(java.lang.String prefix) Retrieves prefix + " in " + elapsedTime() + " ns."- Parameters:
- prefix- The string to use as a prefix
- Returns:
- prefix + " in " + elapsedTime() + " ns."
 
 - 
toStringpublic java.lang.String toString() Retrieves the internal state of this object, as a String. The retrieved value is:super.toString() + "[running=" + running + ", startTime=" + startTime + ", total=" + total + "]";- Overrides:
- toStringin class- java.lang.Object
- Returns:
- the state of this object, as a String
 
 
- 
 
-