Protomatter Classes v1.1.6

com.protomatter.util
Class OpTimer

java.lang.Object
  |
  +--com.protomatter.util.OpTimer
All Implemented Interfaces:
java.io.Serializable

public class OpTimer
extends java.lang.Object
implements java.io.Serializable

A benchmarking utility class. Basically encapsulates a name, start time and end time.

Usually used like this:

  OpTimer timer = new OpTimer("Some long operation");
  ...
  // a lot of junk
  ...
  timer.stop();
  Syslog.debug(this, timer);
  

This class can be used in conjunction with the OpTimerUtil class, which can parse log files for timer traces and produce aggregate timing information.

See Also:
OpTimerUtil, Serialized Form

Constructor Summary
OpTimer(java.lang.String name)
          Create a new timer with the given name.
OpTimer(java.lang.String name, boolean showThread)
          Create a new timer with the given name.
 
Method Summary
 long elapsed()
          Return elapsed time.
 java.lang.String getName()
          Get the name of this timer.
 void setName(java.lang.String name)
          Set the name of this timer.
 OpTimer start()
          Re-start the timer.
 long startTime()
          Get the start time of this timer.
 OpTimer stop()
          Stop the timer.
 long stopTime()
          Get the time this timer was stopped.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OpTimer

public OpTimer(java.lang.String name)
Create a new timer with the given name. The timer is started when it is created.

OpTimer

public OpTimer(java.lang.String name,
               boolean showThread)
Create a new timer with the given name. The timer is started when it is created.
Method Detail

start

public OpTimer start()
Re-start the timer. There's no need to call this method if you're not re-using timer instances. Returns this timer for convenience.

elapsed

public long elapsed()
Return elapsed time.

getName

public java.lang.String getName()
Get the name of this timer.

setName

public void setName(java.lang.String name)
Set the name of this timer.

startTime

public long startTime()
Get the start time of this timer.

stopTime

public long stopTime()
Get the time this timer was stopped. If the timer is still running, the stop time will be 0.

stop

public OpTimer stop()
Stop the timer. Returns this timer instance for convenience.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Protomatter Classes v1.1.6
Copyright 1998-2001 Nate Sammons

Protomatter Classes v1.1.6 http://protomatter.sourceforge.net/1.1.6