Class LatencyAccumulator

java.lang.Object
org.terracotta.statistics.derived.latency.LatencyAccumulator
All Implemented Interfaces:
LatencyStatistic, ChainedEventObserver, ChainedObserver

public class LatencyAccumulator extends Object implements LatencyStatistic, ChainedEventObserver
This accumulator accumulate latency metrics. It is lock-free so when computing some values,it is possible that a thread is writing some values while the snapshot is being computed. So there is the possibility of an error in the result.
  • Field Details

  • Constructor Details

    • LatencyAccumulator

      private LatencyAccumulator(long... latencies)
  • Method Details

    • accumulate

      public void accumulate(long latency)
    • accumulate

      public void accumulate(LatencyAccumulator accumulator)
    • count

      public long count()
    • total

      public long total()
    • isEmpty

      public boolean isEmpty()
    • event

      public void event(long time, long latency)
      Description copied from interface: ChainedEventObserver
      Called to indicate an event happened.
      Specified by:
      event in interface ChainedEventObserver
      Parameters:
      time - the clock at event completion in ns
      latency - the event latency in ns
    • maximum

      public Long maximum()
      Specified by:
      maximum in interface LatencyStatistic
      Returns:
      The maximum in ns or null if it does not exist yet
    • minimum

      public Long minimum()
      Specified by:
      minimum in interface LatencyStatistic
      Returns:
      The minimum in ns or null if it does not exist yet
    • average

      public double average()
      Specified by:
      average in interface LatencyStatistic
      Returns:
      The average in ns or NaN if no value
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • accumulator

      public static LatencyAccumulator accumulator(long... latencies)
    • empty

      public static LatencyAccumulator empty()