

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("#.##") |
Class that facilitates runtime profiling.
| 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.
| logger | the logger to be used in logLapTime(String). If null, a new JDK logger will be constructed on demand. |
| 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.
References m_startTime.
Referenced by alma::acs::container::AcsContainer::activate_component(), alma::acs::container::corba::AcsCorba::deactivateComponentPOAManager(), alma::acs::container::ContainerSealant::invoke(), alma::acs::logging::engine::io::IOHelper::loadLogs(), alma::acs::nc::Consumer::processEvent(), alma::acs::jlog::test::LogDispatcherTest::testBinaryDispatch(), alma::acs::container::corba::ClientPendingReplyTimeoutTest::testClientPendingReplyTimeout(), alma::acs::concurrent::ThreadLoopRunnerTest::testComplexWithSuspendAndRestart(), alma::jconttest::ContainerServicesTesterImpl::ContainerServicesTesterImpl::testGetReferenceWithCustomClientSideTimeout(), alma::acs::concurrent::ThreadBurstExecutorServiceTest::testParallelExecutor(), alma::acs::container::ComponentTestclient::testTimeout(), and alma::acs::jlog::test::LogDispatcherTest::testXMLDispatch().
| 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.
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
| taskDesc | the message to be include in the standard message which should describe the task for which the lap time is taken. |
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] |
Reimplemented in alma::acs::time::Profiler.
References m_startTime, and m_startTimeNanos.
Referenced by alma::acs::nc::Consumer::processEvent(), StopWatch(), alma::acs::jlog::test::LogDispatcherTest::testBinaryDispatch(), alma::acs::concurrent::ThreadLoopRunnerTest::testComplexWithSuspendAndRestart(), alma::acs::daemontest::ServicesDaemonTest::testNamingSrvStartStopCheckCallback(), and alma::acs::jlog::test::LogDispatcherTest::testXMLDispatch().
| void alma::acs::util::StopWatch::setLogger | ( | Logger | logger | ) | [inline] |
References m_logger.
Referenced by alma::acs::container::AcsContainerRunner::run().
Logger alma::acs::util::StopWatch::m_logger [private] |
Referenced by logLapTime(), setLogger(), and StopWatch().
long alma::acs::util::StopWatch::m_startTime [private] |
Referenced by getLapTimeMillis(), and reset().
long alma::acs::util::StopWatch::m_startTimeNanos [private] |
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().
1.6.2