public interface Timer
Timer is a base interface for various timer implementations
provided in this package. Each of them can be started and stopped,
and can return the total elapsed time, however each implementation
will interpret elapsed time differently (e.g. wall time, user time,
system time, etc.).
This was inspired by and loosely based on //google3/base/timer.h.TimerFactory| Modifier and Type | Method and Description |
|---|---|
long |
getNanoseconds()
Get the number of nanoseconds that elapsed between when the
Timer was started and when it was stopped. |
void |
start()
Start the timer running.
|
void |
stop()
Stop the timer.
|
void |
update()
Update any internal state.
|
void start()
IllegalStateException - If it was already running.void stop()
IllegalStateException - If it was not running.long getNanoseconds()
Timer was started and when it was stopped. Note that the
return value has nanosecond precision but not necessarily
nanosecond accuracy.void update()
Timer
implementations may take snapshots of data that may be
unavailable in the future. Clients should call this method
periodically to qensure that any state is being updated. For an
example, see JmxThreadGroupCpuTimer.update().Copyright © 2022. All rights reserved.