SolarMetric Kodo JDO 3.0.3 generated on February 20 2004

com.solarmetric.manage
Class TimeWatch

java.lang.Object
  |
  +--com.solarmetric.manage.TimeWatch
All Implemented Interfaces:
Watchable

public class TimeWatch
extends Object
implements Watchable

A TimeWatch allows for marking code blocks and recording execution time statistics.

An example use would be:

TimeWatch tw = new TimeWatch (manager, "MyTimeWatch");

TimeWatch.Token token = tw.createToken ("namedBlock");

// do stuff to be timed.

token.stop ();

A more common use in Kodo would be:

KodoPersistenceManager kpm = ...;

TimeWatch tw = KodoTimeWatchManager.getTimeWatch (kpm);

TimeWatch.Token token = tw.createToken ("namedBlock");

// do stuff to be timed.

token.stop ();

Another typical use would be for timing iterations:

KodoPersistenceManager kpm = ...;

TimeWatch tw = KodoTimeWatchManager.getTimeWatch (kpm);

TimeWatch.Token token = tw.createToken ("namedBlock");

while (...)

{

// do stuff to be timed.

token.stop ();

}

Another typical use when timing iterations:

KodoPersistenceManager kpm = ...;

TimeWatch tw = KodoTimeWatchManager.getTimeWatch (kpm);

TimeWatch.Token token = tw.createToken ("namedBlock");

while (...)

{

// do stuff not to be timed.

token.restart ();

// do stuff to be timed.

token.stop ();

}


Inner Class Summary
static class TimeWatch.Token
          A timer token.
 
Constructor Summary
TimeWatch()
          Create a new TimeWatch Watchable with the passed name.
 
Method Summary
 boolean addListener(WatchableListener listener)
          Add a listener.
 void clearListeners()
          Clear all listeners.
 TimeWatch.Token createToken(String name)
          Create a timer token.
 Collection getStatistics()
          Get a collection of available statistics.
 boolean removeListener(WatchableListener listener)
          Remove a listener.
 void setLog(org.apache.commons.logging.Log log)
          Set the log for this object to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeWatch

public TimeWatch()
Create a new TimeWatch Watchable with the passed name.
Method Detail

createToken

public TimeWatch.Token createToken(String name)
Create a timer token.

setLog

public void setLog(org.apache.commons.logging.Log log)
Set the log for this object to use.

addListener

public boolean addListener(WatchableListener listener)
Add a listener.
Specified by:
addListener in interface Watchable

removeListener

public boolean removeListener(WatchableListener listener)
Remove a listener.
Specified by:
removeListener in interface Watchable

clearListeners

public void clearListeners()
Clear all listeners.
Specified by:
clearListeners in interface Watchable

getStatistics

public Collection getStatistics()
Get a collection of available statistics. Items are of type Statistic.
Specified by:
getStatistics in interface Watchable

SolarMetric Kodo JDO 3.0.3 generated on February 20 2004

Copyright 2001,2002 SolarMetric, Inc. All Rights Reserved.