@NotThreadSafe public class PerformanceLogger extends Object
This class is meant to be used like this:
//...
PerformanceLogger plog = new PerformanceLogger();
doWork();
plog.logElapsedAndRestart();
doSomeMoreWork();
plog.logElapsed();
//...
For logging SLF4J with log level DEBUG is used; you can therefore disable
performance logging by simply setting the log level for this class accordingly.
| Constructor and Description |
|---|
PerformanceLogger()
Constructs a new
PerformanceLogger with no threshold. |
PerformanceLogger(long threshold)
Constructs a new
PerformanceLogger. |
| Modifier and Type | Method and Description |
|---|---|
void |
logElapsed()
See
logElapsed(String). |
void |
logElapsed(String msg)
Logs the elapsed time if it is above the threshold.
|
void |
logElapsedAndRestart()
|
void |
logElapsedAndRestart(String msg)
Logs the elapsed time if it is above the threshold and restarts the internal timer.
|
void |
restart()
Restarts the internal timer.
|
public PerformanceLogger()
PerformanceLogger with no threshold.public PerformanceLogger(long threshold)
PerformanceLogger.threshold - the threshold in ms for which the logger should generate any output.public void logElapsed()
logElapsed(String).public void logElapsedAndRestart()
public void logElapsed(String msg)
msg - an optional message.public void logElapsedAndRestart(String msg)
msg - an optional message.public void restart()
Copyright © 2012-2013 IP SQUARE. All Rights Reserved.