com.diasparsoftware.gsbase
Interface Stopwatch

All Known Implementing Classes:
SystemClockStopwatch

public interface Stopwatch

A simple timing device you can use to time any event. Sample use.

 Stopwatch stopwatch = new SystemClockStopwatch();
 // Your event starts...
 stopwatch.start();
 // Your event goes on...
 // Your event ends...
 stopwatch.stop();
 long timeInMilliseconds = stopwatch.getLastTime();
 stopwatch.reset();
 // Next event starts...
 stopwatch.start();
 // And so on...
 

Version:
$Revision: 1.1 $
Author:
J. B. Rainsberger

Method Summary
 long getLastTime()
          Returns the last time interval recorded by the stopwatch.
 void reset()
          Resets the stopwatch, clearing the last time and preparing the shopwatch to be started again.
 void start()
          Start the stopwatch.
 void stop()
          Stops the stopwatch.
 

Method Detail

start

public void start()
Start the stopwatch. This method will restart the stopwatch if it is already running.


stop

public void stop()
Stops the stopwatch. This method has no effect if the stopwatch is already stopped.


reset

public void reset()
Resets the stopwatch, clearing the last time and preparing the shopwatch to be started again.


getLastTime

public long getLastTime()
Returns the last time interval recorded by the stopwatch. Formally, this is the difference in time between when you last invoked stop() after having invoked start().

Returns:
The last time interval recorded by the stopwatch, or 0 if the stopwatch has been reset or never used.


Copyright © 2003-2004 Diaspar Software Services, Inc.. All Rights Reserved.