ostore.util
Class StopWatch

java.lang.Object
  |
  +--ostore.util.StopWatch

public class StopWatch
extends Object

StopWatch provides timing utilities for profiling code performance. This class relies on Date, and therefore can provide only millisecond-granularity timing.

All timestamps are retrieved from Clock.current_date(ostore.util.NodeId), so this class is simulator-safe.

Version:
$Id: StopWatch.java,v 1.5 2002/01/08 18:26:12 geels Exp $
Author:
Dennis Geels

Method Summary
static StopWatch getInstance(NodeId node_id)
          Returns the StopWatch instance corresponding to a NodeId.
 long split(Object tag)
          Return the time elapsed so far, in milliseconds.
 void start(Object tag)
          Start a new timer.
 long stop(Object tag)
          Stop a timer and return the time elapsed, in milliseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static StopWatch getInstance(NodeId node_id)
Returns the StopWatch instance corresponding to a NodeId.

Parameters:
node_id - The NodeId which parameterizes a virtual SandStorm instance.
Returns:
the (possibly new) StopWatch instance corresponding to node_id.

start

public final void start(Object tag)
Start a new timer.

Parameters:
tag - The identifier for this timing. May be reused.

split

public final long split(Object tag)
Return the time elapsed so far, in milliseconds. This method does not stop or reset a timer; successive calls return the monotonically increasing cumulative time elapsed.

Parameters:
tag - The identifier for this timing.
Returns:
the time since the last call to start with this tag, or 0 if no such call was made.

stop

public final long stop(Object tag)
Stop a timer and return the time elapsed, in milliseconds. This method clears the tag's state from the StopWatch, effectively resetting the timer.

Parameters:
tag - The identifier for this timing.
Returns:
the time since the last call to start with this tag, or 0 if no such call was made.