public class PerfLogger extends Object
Modifier and Type | Field and Description |
---|---|
protected Map<String,Long> |
endTimes |
protected static ThreadLocal<PerfLogger> |
perfLogger |
protected Map<String,Long> |
startTimes |
protected Map<String,com.codahale.metrics.Timer.Context> |
timerContexts |
Modifier and Type | Method and Description |
---|---|
void |
cleanupPerfLogMetrics()
Cleans up any dangling perfLog metric call scopes.
|
boolean |
endTimeHasMethod(String method) |
Long |
getDuration(String method) |
Long |
getEndTime(String method) |
com.google.common.collect.ImmutableMap<String,Long> |
getEndTimes() |
static PerfLogger |
getPerfLogger(boolean resetPerfLogger)
Get the singleton PerfLogger instance.
|
Long |
getStartTime(String method) |
com.google.common.collect.ImmutableMap<String,Long> |
getStartTimes() |
void |
PerfLogBegin(String callerName,
String method)
Call this function when you start to measure time spent by a piece of code.
|
long |
PerfLogEnd(String callerName,
String method)
Call this function in correspondence of PerfLogBegin to mark the end of the measurement.
|
long |
PerfLogEnd(String callerName,
String method,
String additionalInfo)
Call this function in correspondence of PerfLogBegin to mark the end of the measurement.
|
static void |
setPerfLogger(PerfLogger resetPerfLogger) |
boolean |
startTimeHasMethod(String method) |
protected static final ThreadLocal<PerfLogger> perfLogger
public static PerfLogger getPerfLogger(boolean resetPerfLogger)
resetPerfLogger
- if false, get the current PerfLogger, or create a new one if a
current one does not exist. If true, a new instance of PerfLogger
will be returned rather than the existing one. Note that the
existing PerfLogger is not shutdown and any object which already has a
reference to it may continue to use it. But all future calls to this
method with this set to false will get the new PerfLogger instance.public static void setPerfLogger(PerfLogger resetPerfLogger)
public void PerfLogBegin(String callerName, String method)
callerName
- the logging object to be used.method
- method or ID that identifies this perf log element.public long PerfLogEnd(String callerName, String method)
callerName
- method
- public long PerfLogEnd(String callerName, String method, String additionalInfo)
callerName
- method
- public boolean startTimeHasMethod(String method)
public boolean endTimeHasMethod(String method)
public void cleanupPerfLogMetrics()
Copyright © 2022 The Apache Software Foundation. All rights reserved.