All Superinterfaces:
Meter

public interface Timer extends Meter
Represents a timer.
Author:
Holger Eichelberger, SSE
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Default implementation of Timer.Sample based on micrometer.
    static interface 
    Maintains state on the clock's start position for a latency sample.
    static interface 
    Builds a timer.

    Nested classes/interfaces inherited from interface de.iip_ecosphere.platform.support.metrics.Meter

    Meter.Id, Meter.Type
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the base time unit.
    long
    Returns the number of times that stop has been called on this timer.
    double
    max(TimeUnit unit)
    Returns the maximum time of a single event.
    double
    mean(TimeUnit unit)
    Returns the mean/average for all recorded events.
    void
    record(long amount, TimeUnit unit)
    Updates the statistics kept by the timer with the specified amount.
    void
    Executes the runnable func and records the time taken.
    <T> T
    record(Supplier<T> supplier)
    Executes the Supplier supplier and records the time taken.
    <T> T
    recordCallable(Callable<T> function)
    Executes the callable function and records the time taken.
    double
    Returns the total time of recorded events.

    Methods inherited from interface de.iip_ecosphere.platform.support.metrics.Meter

    getId, getName, measure
  • Method Details

    • record

      void record(Runnable func)
      Executes the runnable func and records the time taken.
      Parameters:
      func - function to execute and measure the execution time
    • record

      void record(long amount, TimeUnit unit)
      Updates the statistics kept by the timer with the specified amount.
      Parameters:
      amount - Duration of a single event being measured by this timer. If the amount is less than 0 the value will be dropped
      unit - Time unit for the amount being recorded
    • record

      <T> T record(Supplier<T> supplier)
      Executes the Supplier supplier and records the time taken.
      Type Parameters:
      T - The return type of the supplier.
      Parameters:
      supplier - Function to execute and measure the execution time.
      Returns:
      The return value of supplier.
    • recordCallable

      <T> T recordCallable(Callable<T> function) throws Exception
      Executes the callable function and records the time taken.
      Type Parameters:
      T - The return type of the Callable.
      Parameters:
      function - Function to execute and measure the execution time.
      Returns:
      The return value of function.
      Throws:
      Exception - Any exception bubbling up from the callable.
    • count

      long count()
      Returns the number of times that stop has been called on this timer.
      Returns:
      the number of times
    • baseTimeUnit

      TimeUnit baseTimeUnit()
      Returns the base time unit.
      Returns:
      the base time unit of the timer to which all published metrics will be scaled
    • max

      double max(TimeUnit unit)
      Returns the maximum time of a single event.
      Parameters:
      unit - The base unit of time to scale the max to
      Returns:
      The maximum time of a single event
    • totalTime

      double totalTime(TimeUnit unit)
      Returns the total time of recorded events.
      Parameters:
      unit - The base unit of time to scale the total to
      Returns:
      The total time of recorded events
    • mean

      double mean(TimeUnit unit)
      Returns the mean/average for all recorded events.
      Parameters:
      unit - The base unit of time to scale the mean to
      Returns:
      the distribution average for all recorded events