public class SimpleOpTimer extends Object implements OpTimer
These are ONE TIME USE objects.
Once end() has been called they cannot be called again and WILL throw IllegalStateException if you try.
You can however ask for a snapshot() at any time if you want but that is a secondary use case.
The cpu time is based on the Java JMX ThreadMXBean.getCurrentThreadCpuTime() and hence this object should not
be shared amongst multiple threads otherwise the value is meaningless.
OpTimer.HeisenburgResultSetCalculator, OpTimer.OnEndCallback| Constructor and Description |
|---|
SimpleOpTimer(String name)
Once you construct a SimpleOpTimer, the timer is started.
|
SimpleOpTimer(String name,
boolean captureCPUCost,
OpTimer.OnEndCallback onEndCallback) |
| Modifier and Type | Method and Description |
|---|---|
OpSnapshot |
end()
Call this in a finally{} block or at the end of the operation to stop the clock
|
OpSnapshot |
end(long resultSetSize)
Call this in a finally{} block or at the end of the operation to stop the clock
|
OpSnapshot |
end(OpTimer.HeisenburgResultSetCalculator heisenburgResultSetCalculator)
Call this in a finally{} block or at the end of the operation to stop the clock
|
OpSnapshot |
endWithTime(long timeInMillis)
Call this in a finally{} block or at the end of the operation with the time taken by the operation
|
String |
getName()
The name of the timer.
|
OpSnapshot |
snapshot()
This will return a snap shot of how long the timer has been running for.
|
public SimpleOpTimer(String name)
name - the name of the operation being timedpublic SimpleOpTimer(String name, boolean captureCPUCost, OpTimer.OnEndCallback onEndCallback)
public String getName()
OpTimerpublic OpSnapshot snapshot()
OpTimerpublic OpSnapshot end(long resultSetSize)
OpTimerpublic OpSnapshot end()
OpTimerThe result set size will be set to Double.NAN.
public OpSnapshot end(OpTimer.HeisenburgResultSetCalculator heisenburgResultSetCalculator)
OpTimerpublic OpSnapshot endWithTime(long timeInMillis)
OpTimerendWithTime in interface OpTimertimeInMillis - Time taken by the operationCopyright © 2016 Atlassian. All rights reserved.