public class StatisticsAccumulator
extends java.lang.Object
StatisticsAccumulator accumulates the samples provided by the user and computes the value of minimum, maximum, sum and sample square sum. When the StatisticMonitoredAttribute calls getValue(), it will compute all the statistics for the collected samples (Which are Minimum, Maximum, Average, StandardDeviation) and provides a nice printable record as a String. Users can easily extend this class and provide the implementation of toString() method to format the stats as desired. By default all the stats are printed in a single line.
Constructor and Description |
---|
StatisticsAccumulator(java.lang.String unit)
Construct the Statistics Accumulator by providing the unit as a String.
|
Modifier and Type | Method and Description |
---|---|
void |
augment(StatisticsAccumulator acc) |
double |
average() |
void |
clearState()
Clears the samples and starts fresh on new samples.
|
long |
count() |
Statistics |
getStats() |
java.lang.String |
getValue()
Computes the Standard Statistic Results based on the samples collected
so far and provides the complete value as a formatted String
|
double |
max() |
double |
min() |
void |
sample(double value) |
double |
standardDeviation() |
java.lang.String |
toString()
Users can extend StatisticsAccumulator to provide the complete
Stats in the format they prefer, if the default format doesn't suffice.
|
java.lang.String |
unit() |
void |
unitTestValidate(java.lang.String expectedUnit,
double expectedMin,
double expectedMax,
long expectedSampleCount,
double expectedAverage,
double expectedStandardDeviation)
This is an internal API to test StatisticsAccumulator...
|
public StatisticsAccumulator(java.lang.String unit)
unit
- a String representing the units for the samples collectedpublic java.lang.String unit()
public long count()
public double min()
public double max()
public double average()
public double standardDeviation()
public void sample(double value)
public Statistics getStats()
public void augment(StatisticsAccumulator acc)
public java.lang.String getValue()
public java.lang.String toString()
toString
in class java.lang.Object
public void clearState()
public void unitTestValidate(java.lang.String expectedUnit, double expectedMin, double expectedMax, long expectedSampleCount, double expectedAverage, double expectedStandardDeviation)