public class TimedPhase extends Object implements AutoCloseable
Note: This class is NOT thread-safe. Timers are intended to be started once by one thread, and stopped once by one thread (though those threads are not necessarily the same).
Constructor and Description |
---|
TimedPhase(String name)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Stops the timer, and registers the timer with the RequestLog.
|
long |
getDuration()
Return the duration of the timer in nanoseconds.
|
String |
getName() |
TimeUnit |
getUnit() |
boolean |
isRunning() |
void |
registerTime()
Registers the duration of this timer with the RequestLog.
|
TimedPhase |
start()
Start the phase.
|
void |
stop()
Stop the phase.
|
public TimedPhase(String name)
name
- Name of the phasepublic TimedPhase start()
public void stop()
This method just stops the timer. It does not register the time with the RequestLog
. To register
the timer, invoke registerTime()
. To do both with a single method call, see
close()
registerTime()
,
close()
public void registerTime()
public long getDuration()
public String getName()
public TimeUnit getUnit()
public boolean isRunning()
public void close()
This is primarily meant to be used by the try-with-resources block, which both stops the timer and registers it
with the RequestLog, though it can of course be called manually as well. If you want to stop the timer, but
don't want to register the timer just yet, then see stop()
.
close
in interface AutoCloseable
stop()
,
registerTime()
Copyright © 2016–2018 Yahoo! Inc.. All rights reserved.