Top Description Fields Constructors Methods
org.glassfish.pfl.tf.timer.spi

public Class StatisticsAccumulator

extends Object
Class Inheritance

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.

Author
Hemanth Puttaswamy

Field Summary

Modifier and TypeField and Description
private double
private double
private long
pack-priv double
pack-priv double
private Statistics
private String

Constructor Summary

AccessConstructor and Description
public
StatisticsAccumulator(String
a String representing the units for the samples collected
unit
)

Construct the Statistics Accumulator by providing the unit as a String.

Method Summary

Modifier and TypeMethod and Description
public void
public double
public void
clearState()

Clears the samples and starts fresh on new samples.

public long
public synchronized Statistics
public String
getValue()

Computes the Standard Statistic Results based on the samples collected so far and provides the complete value as a formatted String

public double
max()

public double
min()

public void
sample(double value)

public double
public String
toString()

Overrides java.lang.Object.toString.

Users can extend StatisticsAccumulator to provide the complete Stats in the format they prefer, if the default format doesn't suffice.

public String
unit()

public void
unitTestValidate(String expectedUnit, double expectedMin, double expectedMax, long expectedSampleCount, double expectedAverage, double expectedStandardDeviation)

This is an internal API to test StatisticsAccumulator...

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

maxback to summary
private double max
minback to summary
private double min
sampleCountback to summary
private long sampleCount
sampleSquareSumback to summary
pack-priv double sampleSquareSum
sampleSumback to summary
pack-priv double sampleSum
statsback to summary
private Statistics stats
unitback to summary
private String unit

Constructor Detail

StatisticsAccumulatorback to summary
public StatisticsAccumulator(String unit)

Construct the Statistics Accumulator by providing the unit as a String. The examples of units are "Hours", "Minutes", "Seconds", "MilliSeconds", "Micro Seconds" etc.,

Parameters
unit:String

a String representing the units for the samples collected

Method Detail

augmentback to summary
public void augment(StatisticsAccumulator acc)
averageback to summary
public double average()
clearStateback to summary
public void clearState()

Clears the samples and starts fresh on new samples.

countback to summary
public long count()
getStatsback to summary
public synchronized Statistics getStats()
getValueback to summary
public String getValue()

Computes the Standard Statistic Results based on the samples collected so far and provides the complete value as a formatted String

maxback to summary
public double max()
minback to summary
public double min()
sampleback to summary
public void sample(double value)
standardDeviationback to summary
public double standardDeviation()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Users can extend StatisticsAccumulator to provide the complete Stats in the format they prefer, if the default format doesn't suffice.

unitback to summary
public String unit()
unitTestValidateback to summary
public void unitTestValidate(String expectedUnit, double expectedMin, double expectedMax, long expectedSampleCount, double expectedAverage, double expectedStandardDeviation)

This is an internal API to test StatisticsAccumulator...