Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

alma::acs::util::StopWatch Class Reference

Inheritance diagram for alma::acs::util::StopWatch:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 StopWatch ()
 StopWatch (Logger logger)
void setLogger (Logger logger)
void reset ()
long getLapTimeMillis ()
long getLapTimeNanos ()
void logLapTime (String taskDesc)

Private Attributes

Logger m_logger
long m_startTime
long m_startTimeNanos

Static Private Attributes

boolean s_shutup = false
final NumberFormat millisecFormatter = new DecimalFormat("#.##")

Detailed Description

Class that facilitates runtime profiling.

Author:
hsommer May 7, 2003 2:18:39 PM


Constructor & Destructor Documentation

alma::acs::util::StopWatch::StopWatch  )  [inline]
 

Ctor without logger provided. Either call setLogger later, or there will be a JDK logger used on demand.

alma::acs::util::StopWatch::StopWatch Logger  logger  )  [inline]
 

Constructor that resets the time count.

Parameters:
logger the logger to be used in logLapTime(String). If null, a new JDK logger will be constructed on demand.


Member Function Documentation

long alma::acs::util::StopWatch::getLapTimeMillis  )  [inline]
 

Gets the time in milliseconds that has elapsed since this object was created or reset() was called.

The implementation simply relies on System.currentTimeMillis(), so that the granularity of measurements is OS dependent and can be much more than one ms. Also, note that the time spent on all threads together is returned, which might be a poor measure for runtime profiling a particular method.

Returns:
elapsed time in milliseconds

long alma::acs::util::StopWatch::getLapTimeNanos  )  [inline]
 

Gets the time in nanoseconds that has elapsed since this object was created or reset() was called.

The implementation simply relies on System.nanoTime(), so that the granularity of measurements is OS dependent. Also, note that the time spent on all threads together is returned, which might be a poor measure for runtime profiling a particular method.

Returns:
elapsed time in nanoseconds

void alma::acs::util::StopWatch::logLapTime String  taskDesc  )  [inline]
 

Logs a message about the elapsed time for a certain task. It uses log level Level.FINE and inserts the supplied description: "<code>elapsed time in ms to </code><i>taskDescription</i><code>: </code><i>elapsed-time</i>".

If no logger has been supplied, it will get one using Logger#getLogger(java.lang.String). This ad-hoc logger will likely not work in an ACS environment where log handlers are configured for the needs of containers and remote logging.

todo: provide nicer text mask for message

Parameters:
taskDesc the message to be include in the standard message which should describe the task for which the lap time is taken.
See also:
getLapTimeMillis()

void alma::acs::util::StopWatch::reset  )  [inline]
 

Reimplemented in alma::acs::time::Profiler.

void alma::acs::util::StopWatch::setLogger Logger  logger  )  [inline]
 


Member Data Documentation

Logger alma::acs::util::StopWatch::m_logger [private]
 

long alma::acs::util::StopWatch::m_startTime [private]
 

long alma::acs::util::StopWatch::m_startTimeNanos [private]
 

final NumberFormat alma::acs::util::StopWatch::millisecFormatter = new DecimalFormat("#.##") [static, private]
 

When printing elapsed time in millisec, we only want to show two fractional digits.

boolean alma::acs::util::StopWatch::s_shutup = false [static, private]
 


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:54:36 2009 for ACS Java API by doxygen 1.3.8