ahc.util.timer
Class StopWatch

java.lang.Object
  |
  +--ahc.util.timer.StopWatch

public class StopWatch
extends java.lang.Object

This class serves to measure time in "experiments", i.e. in a test environment. The metaphor is a stop watch.

The time starts when the StopWatch is created, and it runs until "stop" is called. Calls to "current" return the current time in milliseconds since the watch was started or - if it was stopped - between the start and the stop.

It is posssible to take the time for intermediate results by calling "remember". Such a call saves the current time together with an identifying string so that it is later possible to get a list of all intermediate events with their respective times.

The toString method returns a human readable string representation of the entire measurement.

Note that for meaningful performance measurements it is often necessary to execute the measured code several times. TimerExperiment provides support for that.

Author:
Arno Haase

Constructor Summary
StopWatch(java.lang.String name)
           
 
Method Summary
 long current()
           
 java.util.List getEvents()
           
 java.lang.String getName()
           
 boolean isRunning()
           
 void remember(java.lang.String event)
           
 void stop()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StopWatch

public StopWatch(java.lang.String name)
Method Detail

current

public long current()

stop

public void stop()

remember

public void remember(java.lang.String event)

getEvents

public java.util.List getEvents()

isRunning

public boolean isRunning()

getName

public java.lang.String getName()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object