Interface Timer

All Known Implementing Classes:
AbstractIntervalTimer, CpuRatioTimer

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.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Get the number of nanoseconds that elapsed between when the Timer was started and when it was stopped.
    void
    Start the timer running.
    void
    Stop the timer.
    void
    Update any internal state.
  • Method Details

    • start

      void start()
      Start the timer running.
      Throws:
      IllegalStateException - If it was already running.
    • stop

      void stop()
      Stop the timer.
      Throws:
      IllegalStateException - If it was not running.
    • getNanoseconds

      long getNanoseconds()
      Get the number of nanoseconds that elapsed between when the Timer was started and when it was stopped. Note that the return value has nanosecond precision but not necessarily nanosecond accuracy.
    • update

      void update()
      Update any internal state. For example, some 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 update().