Interface SimpleTimer

  • All Superinterfaces:
    Counting, Metric

    public interface SimpleTimer
    extends Metric, Counting
    A simple timer metric which tracks elapsed time durations and count. This is a lightweight alternative to (@link Timer). The simple timer measures duration in nanoseconds.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  SimpleTimer.Context
      A timing context.
    • Method Detail

      • update

        void update​(java.time.Duration duration)
        Adds a recorded duration.
        Parameters:
        duration - the length of the duration
      • time

        <T> T time​(java.util.concurrent.Callable<T> event)
            throws java.lang.Exception
        Times and records the duration of event.
        Type Parameters:
        T - the type of the value returned by event
        Parameters:
        event - a Callable whose Callable.call() method implements a process whose duration should be timed
        Returns:
        the value returned by event
        Throws:
        java.lang.Exception - if event throws an Exception
      • time

        void time​(java.lang.Runnable event)
        Times and records the duration of event.
        Parameters:
        event - a Runnable whose Runnable.run() method implements a process whose duration should be timed
      • getElapsedTime

        java.time.Duration getElapsedTime()
        Returns the total elapsed timing durations of all completed timing events that are recorded with update(Duration).
        Returns:
        the elapsed time duration
      • getCount

        long getCount()
        Description copied from interface: Counting
        Returns the current count.
        Specified by:
        getCount in interface Counting
        Returns:
        the current count