Package org.slf4j.profiler
Class StopWatch
- java.lang.Object
-
- org.slf4j.profiler.StopWatch
-
- All Implemented Interfaces:
TimeInstrument
public class StopWatch extends java.lang.Object implements TimeInstrument
A very basicTimeInstrumentwhich can be started and stopped once and only once.- Author:
- Ceki Gülcü
-
-
Constructor Summary
Constructors Constructor Description StopWatch(java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longelapsedTime()Time elapsed between start and stop, in nanoseconds.java.lang.StringgetName()All time instruments are named entities.org.slf4j.profiler.TimeInstrumentStatusgetStatus()voidlog()If the time instrument has an associated logger, then log information about this time instrument.voidprint()Print information about this time instrument on the console.voidstart(java.lang.String name)Start this time instrument.TimeInstrumentstop()Stop this time instrument.StopWatchstop(long stopTime)java.lang.StringtoString()
-
-
-
Constructor Detail
-
StopWatch
public StopWatch(java.lang.String name)
-
-
Method Detail
-
start
public void start(java.lang.String name)
Description copied from interface:TimeInstrumentStart this time instrument.- Specified by:
startin interfaceTimeInstrument- Parameters:
name- the name of this instrument
-
getName
public java.lang.String getName()
Description copied from interface:TimeInstrumentAll time instruments are named entities.- Specified by:
getNamein interfaceTimeInstrument- Returns:
- the name of this instrument
-
stop
public TimeInstrument stop()
Description copied from interface:TimeInstrumentStop this time instrument.- Specified by:
stopin interfaceTimeInstrument- Returns:
- this
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
elapsedTime
public final long elapsedTime()
Description copied from interface:TimeInstrumentTime elapsed between start and stop, in nanoseconds.- Specified by:
elapsedTimein interfaceTimeInstrument- Returns:
- time elapsed in nanoseconds
-
getStatus
public org.slf4j.profiler.TimeInstrumentStatus getStatus()
- Specified by:
getStatusin interfaceTimeInstrument
-
print
public void print()
Description copied from interface:TimeInstrumentPrint information about this time instrument on the console.- Specified by:
printin interfaceTimeInstrument
-
log
public void log()
Description copied from interface:TimeInstrumentIf the time instrument has an associated logger, then log information about this time instrument. Note thatStopWatchinstances cannot log whileProfilerinstances can.- Specified by:
login interfaceTimeInstrument
-
-