public class Profiler extends java.lang.Object implements TimeInstrument
| Modifier and Type | Field and Description |
|---|---|
(package private) java.util.List<TimeInstrument> |
childTimeInstrumentList |
(package private) static java.lang.String |
ELAPSED_TIME |
(package private) StopWatch |
globalStopWatch |
(package private) Logger |
logger |
(package private) static int |
MIN_SW_ELAPSED_TIME_NUMBER_LENGTH |
(package private) static int |
MIN_SW_NAME_LENGTH |
(package private) java.lang.String |
name |
(package private) static java.lang.String |
NESTED_PROFILER_FIRST_PREFIX |
(package private) static java.lang.String |
PROFILER_MARKER_NAME |
(package private) ProfilerRegistry |
profilerRegistry |
(package private) static java.lang.String |
SUBTOTAL_ELAPSED |
(package private) static java.lang.String |
TOP_PROFILER_FIRST_PREFIX |
(package private) static java.lang.String |
TOTAL_ELAPSED |
| Constructor and Description |
|---|
Profiler(java.lang.String name) |
| Modifier and Type | Method and Description |
|---|---|
private java.lang.String |
buildProfilerString(DurationUnit du,
java.lang.String firstPrefix,
java.lang.String label,
java.lang.String indentation) |
private static void |
buildStopWatchString(java.lang.StringBuilder buf,
DurationUnit du,
java.lang.String prefix,
java.lang.String indentation,
StopWatch sw) |
long |
elapsedTime()
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.
|
StopWatch |
getCopyOfGlobalStopWatch()
Return a copy of the global stopwatch of this Profiler instance.
|
(package private) TimeInstrument |
getLastTimeInstrument() |
Logger |
getLogger() |
java.lang.String |
getName()
All time instruments are named entities.
|
ProfilerRegistry |
getProfilerRegistry() |
TimeInstrumentStatus |
getStatus() |
void |
log()
If the time instrument has an associated logger, then log information about
this time instrument.
|
void |
print()
Print information about this time instrument on the console.
|
void |
registerWith(ProfilerRegistry profilerRegistry) |
(package private) void |
sanityCheck()
This method is used in tests.
|
void |
setLogger(Logger logger) |
void |
start(java.lang.String name)
Starts a child stop watch and stops any previously started time
instruments.
|
Profiler |
startNested(java.lang.String name) |
TimeInstrument |
stop()
Stop this time instrument.
|
(package private) void |
stopLastTimeInstrument() |
java.lang.String |
toString() |
static final java.lang.String PROFILER_MARKER_NAME
static final int MIN_SW_NAME_LENGTH
static final int MIN_SW_ELAPSED_TIME_NUMBER_LENGTH
final java.lang.String name
final StopWatch globalStopWatch
java.util.List<TimeInstrument> childTimeInstrumentList
ProfilerRegistry profilerRegistry
Logger logger
static java.lang.String TOP_PROFILER_FIRST_PREFIX
static java.lang.String NESTED_PROFILER_FIRST_PREFIX
static java.lang.String TOTAL_ELAPSED
static java.lang.String SUBTOTAL_ELAPSED
static java.lang.String ELAPSED_TIME
public java.lang.String getName()
TimeInstrumentgetName in interface TimeInstrumentpublic ProfilerRegistry getProfilerRegistry()
public void registerWith(ProfilerRegistry profilerRegistry)
public Logger getLogger()
public void setLogger(Logger logger)
public void start(java.lang.String name)
start in interface TimeInstrumentpublic Profiler startNested(java.lang.String name)
TimeInstrument getLastTimeInstrument()
void stopLastTimeInstrument()
public long elapsedTime()
TimeInstrumentelapsedTime in interface TimeInstrumentpublic TimeInstrument stop()
TimeInstrumentstop in interface TimeInstrumentpublic TimeInstrumentStatus getStatus()
getStatus in interface TimeInstrumentvoid sanityCheck()
throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionpublic void print()
TimeInstrumentprint in interface TimeInstrumentpublic java.lang.String toString()
toString in class java.lang.Objectpublic void log()
TimeInstrumentStopWatch instances cannot log while Profiler
instances can.log in interface TimeInstrumentpublic java.util.List<TimeInstrument> getCopyOfChildTimeInstruments()
public StopWatch getCopyOfGlobalStopWatch()
private java.lang.String buildProfilerString(DurationUnit du, java.lang.String firstPrefix, java.lang.String label, java.lang.String indentation)
private static void buildStopWatchString(java.lang.StringBuilder buf,
DurationUnit du,
java.lang.String prefix,
java.lang.String indentation,
StopWatch sw)