netflix.utilities
Class MethodTimer

java.lang.Object
  extended by netflix.utilities.MethodTimer

public class MethodTimer
extends java.lang.Object

This class can be used to profile program execution by keeping track of the time spent in each method and the average time per call. To use this class create a global MethodTimer object, and call the start method at the beginning of every method and stop at the end. At the end of executing the timings can be retrieved using the printTimings function.


Constructor Summary
MethodTimer()
          Default constructor.
 
Method Summary
 void printTimes()
          Prints all the timings managed by this MethodTimer.
 void start(java.lang.String methodName)
          Starts a timer for the specfied method.
 void stop(java.lang.String methodName)
          Ends the tiemr for the specified method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodTimer

public MethodTimer()
Default constructor.

Method Detail

start

public void start(java.lang.String methodName)
Starts a timer for the specfied method. If this is the first time that the method has been called, a new Timing object is created, otherwise the existing one is modfied.

Parameters:
methodName - The method to time.

stop

public void stop(java.lang.String methodName)
          throws java.lang.RuntimeException
Ends the tiemr for the specified method.

Throws:
java.lang.RuntimeException - if the specified method name does not have an associated Timing object.

printTimes

public void printTimes()
Prints all the timings managed by this MethodTimer.