Package org.slf4j.profiler
Class Profiler
- java.lang.Object
-
- org.slf4j.profiler.Profiler
-
- All Implemented Interfaces:
TimeInstrument
public class Profiler extends java.lang.Object implements TimeInstrument
A poor man's profiler to measure the time elapsed performing some lengthy task.- Author:
- Ceki Gülcü
-
-
Constructor Summary
Constructors Constructor Description Profiler(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.util.List<TimeInstrument>getCopyOfChildTimeInstruments()Return a copy of the child instrument list for this Profiler instance.StopWatchgetCopyOfGlobalStopWatch()Return a copy of the global stopwatch of this Profiler instance.org.slf4j.LoggergetLogger()java.lang.StringgetName()All time instruments are named entities.ProfilerRegistrygetProfilerRegistry()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.voidregisterWith(ProfilerRegistry profilerRegistry)voidsetLogger(org.slf4j.Logger logger)voidstart(java.lang.String name)Starts a child stop watch and stops any previously started time instruments.ProfilerstartNested(java.lang.String name)TimeInstrumentstop()Stop this time instrument.java.lang.StringtoString()
-
-
-
Constructor Detail
-
Profiler
public Profiler(java.lang.String name)
-
-
Method Detail
-
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
-
getProfilerRegistry
public ProfilerRegistry getProfilerRegistry()
-
registerWith
public void registerWith(ProfilerRegistry profilerRegistry)
-
getLogger
public org.slf4j.Logger getLogger()
-
setLogger
public void setLogger(org.slf4j.Logger logger)
-
start
public void start(java.lang.String name)
Starts a child stop watch and stops any previously started time instruments.- Specified by:
startin interfaceTimeInstrument- Parameters:
name- the name of this instrument
-
startNested
public Profiler startNested(java.lang.String name)
-
elapsedTime
public long elapsedTime()
Description copied from interface:TimeInstrumentTime elapsed between start and stop, in nanoseconds.- Specified by:
elapsedTimein interfaceTimeInstrument- Returns:
- time elapsed in nanoseconds
-
stop
public TimeInstrument stop()
Description copied from interface:TimeInstrumentStop this time instrument.- Specified by:
stopin interfaceTimeInstrument- Returns:
- this
-
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
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
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
-
getCopyOfChildTimeInstruments
public java.util.List<TimeInstrument> getCopyOfChildTimeInstruments()
Return a copy of the child instrument list for this Profiler instance.- Returns:
- a copy of this instance's child time instrument list
- Since:
- 1.5.9
-
getCopyOfGlobalStopWatch
public StopWatch getCopyOfGlobalStopWatch()
Return a copy of the global stopwatch of this Profiler instance.- Returns:
- a copy of this instance's global stop watch
- Since:
- 1.5.9
-
-