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.
  • Method Details

    • update

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

      <T> T time(Callable<T> event) throws 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:
      Exception - if event throws an Exception
    • time

      void time(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
    • time

      Returns a new SimpleTimer.Context.
      Returns:
      a new SimpleTimer.Context
      See Also:
    • getElapsedTime

      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
    • getMaxTimeDuration

      Duration getMaxTimeDuration()
      Get the maximum recorded time duration of the SimpleTimer for the previously completed full minute.

      This represents the highest timed duration in the last completed full minute. For example if the last completed full minute recorded durations of 12 seconds, 9 seconds and 1 second the largest value is 12 seconds. If no time duration has been recorded in the last completed full minute then a null is returned. If there has only been one time duration recorded in the last completed full minute then this value will be returned by both getMaxTimeDuration() and getMinTimeDuration()

      Returns:
      The maximum recorded time duration in the previously completed full minute or null if no values were recorded
    • getMinTimeDuration

      Duration getMinTimeDuration()
      Get the minimum recorded time duration of the SimpleTimer for the previously completed full minute.

      This represents the lowest timed duration in the last completed full minute. For example if the last completed full minute recorded durations of 12 seconds, 9 seconds and 1 second the lowest value is 1 second. If no time duration has been recorded in the last completed full minute then a null is returned. If there has only been one time duration recorded in the last completed full minute then this value will be returned by both getMaxTimeDuration() and getMinTimeDuration()

      Returns:
      The minimum recorded time duration in the previously completed full minute or null if no values were recorded