Public Member Functions | |
StopWatch () | |
StopWatch (Logger logger) | |
void | setLogger (Logger logger) |
void | reset () |
long | getLapTimeMillis () |
long | getLapTimeNanos () |
void | logLapTime (String taskDesc) |
Class that facilitates runtime profiling.
alma.acs.util.StopWatch.StopWatch | ( | ) |
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 | ) |
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. |
References alma.acs.util.StopWatch.reset().
long alma.acs.util.StopWatch.getLapTimeMillis | ( | ) |
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.
Referenced by alma.acs.container.AcsContainer.activate_component(), alma.COUNTER.CounterConsumerImpl.CounterConsumerImpl.cleanUp(), alma.acs.container.corba.AcsCorba.deactivateComponentPOAManager(), com.cosylab.cdb.jdal.DALImpl.loadRecords(), alma.acs.profiling.orb.OrbProfilerParser.parse(), alma.acs.nc.refactored.NCSubscriber.processEvent(), alma.acs.nc.Consumer.processEvent(), and alma.acs.monitoring.blobber.BlobberWorker.run().
long alma.acs.util.StopWatch.getLapTimeNanos | ( | ) |
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.
Referenced by alma.acs.util.StopWatch.logLapTime().
void alma.acs.util.StopWatch.logLapTime | ( | String | taskDesc | ) |
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 alma.acs.util.StopWatch.getLapTimeNanos().
Referenced by alma.acs.eventbrowser.model.EventModel.getAllSelectedConsumers(), alma.acs.eventbrowser.views.PopulateEventList.getThreadForEventList(), and alma.acs.monitoring.blobber.BlobberWorker.run().
void alma.acs.util.StopWatch.reset | ( | ) |
void alma.acs.util.StopWatch.setLogger | ( | Logger | logger | ) |