be.ac.ua.broker.utils
Class ExecutionTimer

java.lang.Object
  extended by be.ac.ua.broker.utils.ExecutionTimer

public class ExecutionTimer
extends java.lang.Object

This class represents an execution timer, which can be used to time the running of different parts of a Java program. The parts are identified by a uniquely given string key. The ExecutionTimer is used in the benchmarking of the broker.

Author:
Vermeersch Kurt

Constructor Summary
ExecutionTimer()
           
 
Method Summary
 void clear()
          Clear all the timing information from the timer.
 long getElapsedTime(java.lang.String timerName)
          Get the elapsed time by the timer with the given name/key value.
 float getElapsedTimeInSeconds(java.lang.String timerName)
          Get the elapsed time in seconds by the timer with the given name/key value.
 long getTotalElapsedTime()
          Get the total elapsed time by all the different timings.
 float getTotalElapsedTimeInSeconds()
          Get the total elapsed time in seconds by all the different timings.
 void startTiming(java.lang.String timerName)
          Start a timer with a given name
 void stopTiming(java.lang.String timerName)
          Stop the timer with the given name/key
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecutionTimer

public ExecutionTimer()
Method Detail

startTiming

public void startTiming(java.lang.String timerName)
Start a timer with a given name

Parameters:
timerName - name/key of the timer to start running

stopTiming

public void stopTiming(java.lang.String timerName)
                throws java.rmi.activation.UnknownObjectException
Stop the timer with the given name/key

Parameters:
timerName - name/key of the timer to stop running
Throws:
java.rmi.activation.UnknownObjectException - exception thrown when no timer was started previously with the given name/key value

clear

public void clear()
Clear all the timing information from the timer.


getElapsedTime

public long getElapsedTime(java.lang.String timerName)
                    throws java.rmi.activation.UnknownObjectException
Get the elapsed time by the timer with the given name/key value.

Parameters:
timerName - name/key of the timer to get the elapsed time of
Returns:
the elapsed time according to the requested timer.
Throws:
java.rmi.activation.UnknownObjectException - exception thrown when timer was not yet started/stopped

getTotalElapsedTime

public long getTotalElapsedTime()
                         throws java.rmi.activation.UnknownObjectException
Get the total elapsed time by all the different timings. This value is only valuable when the different timers, using different names/key values, are timing consecutive events (they do not overlap) in time.

Returns:
the total elapsed time.
Throws:
java.rmi.activation.UnknownObjectException - exception thrown when timer was not yet started/stopped

getElapsedTimeInSeconds

public float getElapsedTimeInSeconds(java.lang.String timerName)
                              throws java.rmi.activation.UnknownObjectException
Get the elapsed time in seconds by the timer with the given name/key value.

Parameters:
timerName - name/key of the timer to get the elapsed time of
Returns:
the elapsed time in seconds according to the requested timer.
Throws:
java.rmi.activation.UnknownObjectException - exception thrown when timer was not yet started/stopped

getTotalElapsedTimeInSeconds

public float getTotalElapsedTimeInSeconds()
                                   throws java.rmi.activation.UnknownObjectException
Get the total elapsed time in seconds by all the different timings. This value is only valuable when the different timers, using different names/key values, are timing consecutive events (they do not overlap) in time.

Returns:
the total elapsed time in seconds.
Throws:
java.rmi.activation.UnknownObjectException - exception thrown when timer was not yet started/stopped