com.ecyrd.speed4j.log
Class CollectedStatistics

java.lang.Object
  extended by com.ecyrd.speed4j.log.CollectedStatistics

public class CollectedStatistics
extends Object

Represents a statistics item which contains data which has been collected over time. It keeps track of maximum and minimum times, as well as a count, average and standard deviation.

Internally, it keeps the nanosecond accuracy, though most JVMs and operating systems can usually go down to microseconds only. However, all API calls return milliseconds (as doubles), as it's the most useful figure.


Constructor Summary
CollectedStatistics()
           
 
Method Summary
 void add(StopWatch sw)
          Add a StopWatch to the statistics.
 double getAverageMS()
          Returns the average of the StopWatches recorded.
 int getInvocations()
          Returns the number of stopwatches.
 double getMax()
          Returns the slowest StopWatch time recorded.
 double getMin()
          Returns the fastest StopWatch time recorded.
 double getPercentile(int percentile)
          Get the nth percentile.
 double getStdDev()
          Returns the standard deviation of all StopWatches recorded.
 double variance()
          Returns the variance of all StopWatches recorded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectedStatistics

public CollectedStatistics()
Method Detail

add

public void add(StopWatch sw)
Add a StopWatch to the statistics.

Parameters:
sw - StopWatch to add.

getInvocations

public int getInvocations()
Returns the number of stopwatches. This is a fast operation.

Returns:
Number of StopWatches.

getMin

public double getMin()
Returns the fastest StopWatch time recorded. This is a fast operation.

Returns:
Fastest in milliseconds.

getMax

public double getMax()
Returns the slowest StopWatch time recorded. This is a fast operation.

Returns:
Slowest in milliseconds.

getAverageMS

public double getAverageMS()
Returns the average of the StopWatches recorded. NB: This call causes all of the StopWatches to be traversed, which makes it fairly slow.

Returns:
The average in milliseconds.

getStdDev

public double getStdDev()
Returns the standard deviation of all StopWatches recorded. NB: This call causes all of the StopWatches to be traversed, which makes it fairly slow.

Returns:
The standard deviation.

variance

public double variance()
Returns the variance of all StopWatches recorded. NB: This call causes all of the StopWatches to be traversed, which makes it fairly slow.

Returns:
The variance.

getPercentile

public double getPercentile(int percentile)
Get the nth percentile. NB: This is also a fairly slow operation.

Parameters:
percentile - Percentile to get.
Returns:


Copyright © 2011. All Rights Reserved.