Package com.comphenix.protocol.timing
Class HistogramStream
java.lang.Object
com.comphenix.protocol.timing.OnlineComputation
com.comphenix.protocol.timing.HistogramStream
Represents an online algortihm of computing histograms over time.
- Author:
- Kristian
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<StatisticsStream>Each bin in the histogram, indexed by time.protected intThe maximum number of observations in each bin.protected intThe number of total observations.protected StatisticsStreamThe current statistics stream we are updating. -
Constructor Summary
ConstructorsModifierConstructorDescriptionHistogramStream(int binWidth)Construct a new histogram stream which splits up every observation in different bins, ordered by time.HistogramStream(HistogramStream other)Construct a new copy of the given histogram.protectedHistogramStream(List<StatisticsStream> bins, StatisticsStream current, int binWidth)Construct a new histogram stream. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidSee if the current bin has overflowed.copy()Construct a copy of the current online computation.com.google.common.collect.ImmutableList<StatisticsStream>getBins()Retrieve an immutable view of every bin in the histogram.intgetCount()Retrieve the number of observations.getTotal()Retrieve the total statistics of every bin in the histogram.voidobserve(double value)Observe a value.Methods inherited from class com.comphenix.protocol.timing.OnlineComputation
synchronizedComputation
-
Field Details
-
bins
Each bin in the histogram, indexed by time. -
current
The current statistics stream we are updating. -
binWidth
protected int binWidthThe maximum number of observations in each bin. -
count
protected int countThe 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
Construct a new copy of the given histogram.- Parameters:
other- - the histogram to copy.
-
HistogramStream
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
Description copied from class:OnlineComputationConstruct a copy of the current online computation.- Specified by:
copyin classOnlineComputation- Returns:
- The new copy.
-
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:OnlineComputationObserve a value.- Specified by:
observein classOnlineComputation- 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
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:OnlineComputationRetrieve the number of observations.- Specified by:
getCountin classOnlineComputation- Returns:
- Number of observations.
-