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.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringnameprivate longstartTime(package private) TimeInstrumentStatusstatusprivate longstopTime
-
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.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()
-
-
-
Field Detail
-
name
private java.lang.String name
-
startTime
private long startTime
-
stopTime
private long stopTime
-
status
TimeInstrumentStatus status
-
-
Constructor Detail
-
StopWatch
public StopWatch(java.lang.String name)
-
StopWatch
StopWatch(StopWatch original)
-
-
Method Detail
-
start
public void start(java.lang.String name)
Description copied from interface:TimeInstrumentStart this time instrument.- Specified by:
startin interfaceTimeInstrument
-
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
-
stop
public StopWatch stop(long stopTime)
-
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 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
-
-