Class HistogramStream

java.lang.Object
com.comphenix.protocol.timing.OnlineComputation
com.comphenix.protocol.timing.HistogramStream

public class HistogramStream extends OnlineComputation
Represents an online algortihm of computing histograms over time.
Author:
Kristian
  • Field Details

    • bins

      protected List<StatisticsStream> bins
      Each bin in the histogram, indexed by time.
    • current

      protected StatisticsStream current
      The current statistics stream we are updating.
    • binWidth

      protected int binWidth
      The maximum number of observations in each bin.
    • count

      protected int count
      The number of total observations.
  • Constructor Details

    • HistogramStream

      public HistogramStream(int binWidth)
      Construct a new histogram stream which splits up every observation in different bins, ordered by time.
      Parameters:
      binWidth - - maximum number of observations in each bin.
    • HistogramStream

      public HistogramStream(HistogramStream other)
      Construct a new copy of the given histogram.
      Parameters:
      other - - the histogram to copy.
    • HistogramStream

      protected HistogramStream(List<StatisticsStream> bins, StatisticsStream current, int binWidth)
      Construct a new histogram stream.
      Parameters:
      bins - - list of bins.
      current - - the current selected bin. This will be added to the list if it is not already present.
      binWidth - - the desired number of observations in each bin.
  • Method Details

    • copy

      public HistogramStream copy()
      Description copied from class: OnlineComputation
      Construct a copy of the current online computation.
      Specified by:
      copy in class OnlineComputation
      Returns:
      The new copy.
    • getBins

      public com.google.common.collect.ImmutableList<StatisticsStream> getBins()
      Retrieve an immutable view of every bin in the histogram.
      Returns:
      Every bin in the histogram.
    • observe

      public void observe(double value)
      Description copied from class: OnlineComputation
      Observe a value.
      Specified by:
      observe in class OnlineComputation
      Parameters:
      value - - the observed value.
    • checkOverflow

      protected void checkOverflow()
      See if the current bin has overflowed. If so, construct a new bin and set it as the current.
    • getTotal

      public StatisticsStream getTotal()
      Retrieve the total statistics of every bin in the histogram.

      This method is not thread safe.

      Returns:
      The total statistics.
    • getCount

      public int getCount()
      Description copied from class: OnlineComputation
      Retrieve the number of observations.
      Specified by:
      getCount in class OnlineComputation
      Returns:
      Number of observations.