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

Inheritance diagram for alma::acs::util::StopWatch:
Inheritance graph
[legend]
Collaboration diagram for alma::acs::util::StopWatch:
Collaboration 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

static boolean s_shutup = false
static 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.

References m_logger, and reset().


Member Function Documentation

long alma::acs::util::StopWatch::getLapTimeMillis (  )  [inline]
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

References m_startTimeNanos.

Referenced by logLapTime().

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()

References getLapTimeNanos(), m_logger, millisecFormatter, and s_shutup.

Referenced by alma::acs::component::dynwrapper::DynamicProxyFactory::checkMethodMatching(), alma::acs::eventbrowser::views::PopulateEventList::getThreadForEventList(), alma::acs::eventbrowser::views::EventDetailTestHarness::parsePttDataEvent(), alma::acs::eventbrowser::views::DynAnyParserTest::parsePttDataEvent(), alma::acs::container::AcsContainerRunner::run(), and alma::acs::daemontest::ServicesDaemonTest::testNamingSrvStartStopCheckCallback().

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

Member Data Documentation

Referenced by logLapTime(), setLogger(), and StopWatch().

Referenced by getLapTimeMillis(), and reset().

Referenced by getLapTimeNanos(), and reset().

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.

Referenced by logLapTime().

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

Referenced by logLapTime().


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2