ariba.util.core
Class Chrono

java.lang.Object
  extended by ariba.util.core.Chrono
Direct Known Subclasses:
ChronoWithMemory

public class Chrono
extends java.lang.Object

Simple timing class, used for timing one or more trials of an event. The trials must be timed consecutively, so start or stop cannot be called twice in a row.


Constructor Summary
Chrono(java.lang.String name)
          Creates a new instance of a Chrono timer.
Chrono(java.lang.String name, Logger logger)
          Creates a new instance of a Chrono timer.
Chrono(java.lang.String name, Logger logger, int startInfoId, int stopInfoId)
          Creates a new instance of a Chrono timer.
 
Method Summary
 void disable()
          Disables the timer.
 void enable()
          Enables the timer, so that calls to start and stop gather more timing information.
 double getAverageSeconds()
           
 double getTotalSeconds()
           
 int getTrialCount()
           
 void reset()
          Resets the counters to start timing from scratch.
 void start()
          Starts a trial.
 void stop()
          Stops timing the current trial.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Chrono

public Chrono(java.lang.String name)
Creates a new instance of a Chrono timer.

Parameters:
name - the name of the event. Used by toString() to print out the timing summary.

Chrono

public Chrono(java.lang.String name,
              Logger logger)
Creates a new instance of a Chrono timer.

Parameters:
name - the name of the event. Used by toString() to print out the timing summary.
logger - the Logger to use to print debug statements

Chrono

public Chrono(java.lang.String name,
              Logger logger,
              int startInfoId,
              int stopInfoId)
Creates a new instance of a Chrono timer.

Parameters:
name - the name of the event. Used by toString() to print out the timing summary.
logger - the Logger to use to print debug statements
startInfoId - id of a resource for logging an INFO start message to logger.
stopInfoId - id of a resource for logging an INFO stop message to logger.
Method Detail

reset

public void reset()
Resets the counters to start timing from scratch.


start

public void start()
Starts a trial. Must always be called before stop.


stop

public void stop()
Stops timing the current trial.


enable

public void enable()
Enables the timer, so that calls to start and stop gather more timing information.


disable

public void disable()
Disables the timer. Subsequent calls to start and stop will have no effect on timing information.


getTotalSeconds

public double getTotalSeconds()
Returns:
the total number of seconds for all trials

getAverageSeconds

public double getAverageSeconds()
Returns:
the average number of seconds for all trials.

getTrialCount

public int getTrialCount()
Returns:
the number of trials that were timed.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a description of the event, number of trials and timing information


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.