structure
Class Clock

java.lang.Object
  extended by structure.Clock

public class Clock
extends Object

A simple object for measuring time. This Clock allows one to measure time between events. Events may be from several milliseconds to several seconds apart. When measuring events that take considerable time (> 1/10th of a second) it is important to counteract the effect of scheduling of other system processes. A Clock has the following operations:

typical use:
    Clock timer = new Clock();
    timer.start();
    for (i = 0; i < 100000; i++);
    timer.stop();
    System.out.println("Time to count to 100000: "+timer.read()+" seconds.");
 


Constructor Summary
Clock()
          Constructs a stopwatch for timing events to the milliseconds.
 
Method Summary
 double read()
          Read the value on the stop watch.
 void reset()
          Resets the time on the clock to zero.
 void start()
          Start the clock running.
 void stop()
          Stop the clock.
 String toString()
          Generates string representation of clock.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Clock

public Clock()
Constructs a stopwatch for timing events to the milliseconds.

Method Detail

start

public void start()
Start the clock running.


stop

public void stop()
Stop the clock. Time does not accumulate.


read

public double read()
Read the value on the stop watch.

Returns:
A double representing the number of seconds elapsed.

reset

public void reset()
Resets the time on the clock to zero.


toString

public String toString()
Generates string representation of clock.

Overrides:
toString in class Object
Returns:
A string representing this clock.