public class NanoTimer extends SimpleCounter
| Modifier and Type | Field and Description |
|---|---|
private long |
start
start of the operation
|
publishenabled, enabler| Modifier | Constructor and Description |
|---|---|
protected |
NanoTimer(java.util.function.LongConsumer publish)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
static NanoTimer |
getInstance(FwdServerJMX.TimeStat counter)
Create and register instance
|
void |
start()
Start operation
|
void |
stop()
Stop operation and update counter
|
void |
timer(Operation r)
Execute operation and measure execution time
|
<T> T |
timerWithReturn(ReturningOperation<T> r)
Execute operation and measure execution time
|
getInstance, updategetEnabler, isEnabled, setEnabled, setEnablerprotected NanoTimer(java.util.function.LongConsumer publish)
publish - samples' consumerpublic static NanoTimer getInstance(FwdServerJMX.TimeStat counter)
counter - Counter MBeanNanoTimer instancepublic void start()
public void stop()
public void timer(Operation r)
r - operation to be executedpublic <T> T timerWithReturn(ReturningOperation<T> r)
T - The type of the return value for the operation to be executed.r - operation to be executed