com.sun.sgs.impl.profile.util
Class LinearHistogram

java.lang.Object
  extended by com.sun.sgs.impl.profile.util.LinearHistogram
All Implemented Interfaces:
Histogram

public class LinearHistogram
extends Object
implements Histogram

A histogram that bins elements based on provided bounds and a step size. This class is useful for viewing a particular range of data and specifying how the distribution is grouped. The lower and upper bounds should be used to filter out all extraneous data points.


Constructor Summary
LinearHistogram(int lBound, int uBound, long stepSize)
          Creates a linear frequency histogram with the provided lower bound, upper bound and step size.
 
Method Summary
 void bin(long value)
          Updates the state of the histogram by finding the appropriate bin for the provided value and then incrementing the number of samples seen for that bin.
 void clear()
          Clears the internal state of the histogram, removing all collected samples.
 int size()
          Returns the number of samples represented by this histogram.
 String toString()
          Generates a text representation of this linear frequency histogram.
 String toString(String binLabel)
          Generates a text representation of this linear frequency histogram similar to toString() but with labels on bins.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LinearHistogram

public LinearHistogram(int lBound,
                       int uBound,
                       long stepSize)
Creates a linear frequency histogram with the provided lower bound, upper bound and step size.

Parameters:
lBound - the lower bound for the histogram; values strictly less than this will not be included
uBound - the upper bound for the histogram; values strictly greater than this will not be included
stepSize - the maximum range for each bin between lBound and uBound; if stepSize does not evenly divide the difference, the last bin will be truncated in size
Throws:
IllegalArgumentException - if lBound is not less than uBound, or if stepSize is not strictly positive
Method Detail

bin

public void bin(long value)
Updates the state of the histogram by finding the appropriate bin for the provided value and then incrementing the number of samples seen for that bin. Values are binned in the largest bin that is less than the element is incremented. Values less than the lower bound or values that are greater than the upper bound are not counted.

Specified by:
bin in interface Histogram
Parameters:
value - the value to be aggregated

clear

public void clear()
Clears the internal state of the histogram, removing all collected samples.

Specified by:
clear in interface Histogram

size

public int size()
Returns the number of samples represented by this histogram.

Specified by:
size in interface Histogram
Returns:
the number of samples represented by this hisogram

toString

public String toString()
Generates a text representation of this linear frequency histogram. The histogram is presented similar to the following example:
    [lower-bound] |***
    [l.b. + step] |
  [l.b. + 2*step] |*
    [upper-bound] |****
 
Bins that have at least one sample will have a bar displayed. All leading and trailing empty bins are truncated, which may result in the lower and upper bound bins not being displayed. The final line will have a newline at the end.

Specified by:
toString in interface Histogram
Overrides:
toString in class Object
Returns:
a string representation of this histogram

toString

public String toString(String binLabel)
Generates a text representation of this linear frequency histogram similar to toString() but with labels on bins. For example, a bin would appear as:
 200ms |***
 400ms |*
 600ms |*****
 

Specified by:
toString in interface Histogram
Parameters:
binLabel - the label to append to each of the bins
Returns:
a string representation of this histogram

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved