Kodo 4.2.0. generated on July 28 2008

com.solarmetric.manage
Class TimeWatch

java.lang.Object
  extended by 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 ();

}


Nested 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.
 
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.


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

Kodo 4.2.0. generated on July 28 2008

Copyright 2001-2006 BEA Systems, Inc. All Rights Reserved.