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:
    TimerFactory
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method 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.
    • Method Detail

      • start

        void start()
        Start the timer running.
        Throws:
        IllegalStateException - If it was already 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().