Interface Timer

All Superinterfaces:
Counting, Metered, Metric, Sampling

public interface Timer extends Metered, Sampling
A timer metric which aggregates timing durations and provides duration statistics, plus throughput statistics via Meter. The timer measures duration in nanoseconds.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A timing context.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the number of events which have been marked.
    double
    Returns the fifteen-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.
    double
    Returns the five-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.
    double
    Returns the mean rate at which events have occurred since the meter was created.
    double
    Returns the one-minute exponentially-weighted moving average rate at which events have occurred since the meter was created.
    Returns a snapshot of the values.
    Returns a new Timer.Context.
    void
    time(Runnable event)
    Times and records the duration of event.
    <T> T
    time(Callable<T> event)
    Times and records the duration of event.
    void
    update(long duration, TimeUnit unit)
    Adds a recorded duration.
  • Method Details

    • update

      void update(long duration, TimeUnit unit)
      Adds a recorded duration.
      Parameters:
      duration - the length of the duration
      unit - the scale unit of 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 Timer.Context.
      Returns:
      a new Timer.Context
      See Also:
    • getCount

      long getCount()
      Description copied from interface: Metered
      Returns the number of events which have been marked.
      Specified by:
      getCount in interface Counting
      Specified by:
      getCount in interface Metered
      Returns:
      the number of events which have been marked
    • getFifteenMinuteRate

      double getFifteenMinuteRate()
      Description copied from interface: Metered
      Returns the fifteen-minute exponentially-weighted moving average rate at which events have occurred since the meter was created. This rate has the same exponential decay factor as the fifteen-minute load average in the top Unix command.
      Specified by:
      getFifteenMinuteRate in interface Metered
      Returns:
      the fifteen-minute exponentially-weighted moving average rate at which events have occurred since the meter was created
    • getFiveMinuteRate

      double getFiveMinuteRate()
      Description copied from interface: Metered
      Returns the five-minute exponentially-weighted moving average rate at which events have occurred since the meter was created. This rate has the same exponential decay factor as the five-minute load average in the top Unix command.
      Specified by:
      getFiveMinuteRate in interface Metered
      Returns:
      the five-minute exponentially-weighted moving average rate at which events have occurred since the meter was created
    • getMeanRate

      double getMeanRate()
      Description copied from interface: Metered
      Returns the mean rate at which events have occurred since the meter was created.
      Specified by:
      getMeanRate in interface Metered
      Returns:
      the mean rate at which events have occurred since the meter was created
    • getOneMinuteRate

      double getOneMinuteRate()
      Description copied from interface: Metered
      Returns the one-minute exponentially-weighted moving average rate at which events have occurred since the meter was created. This rate has the same exponential decay factor as the one-minute load average in the top Unix command.
      Specified by:
      getOneMinuteRate in interface Metered
      Returns:
      the one-minute exponentially-weighted moving average rate at which events have occurred since the meter was created
    • getSnapshot

      Snapshot getSnapshot()
      Description copied from interface: Sampling
      Returns a snapshot of the values.
      Specified by:
      getSnapshot in interface Sampling
      Returns:
      a snapshot of the values