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

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

public class PowerOfTwoHistogram
extends Object
implements Histogram

A histogram that bins values according to powers of 2.


Constructor Summary
PowerOfTwoHistogram()
          Creates a new power-of-2 frequency histogram.
 
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 power-of-2 frequency histogram.
 String toString(String binLabel)
          Generates a text representation of this power-of-2 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

PowerOfTwoHistogram

public PowerOfTwoHistogram()
Creates a new power-of-2 frequency histogram.

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. Note that this histogram supports only non-negative values; negative values will not be 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 power-of-2 frequency histogram. The histogram is presented similar to the following example:
  8 |***
 16 |
 32 |*
 64 |*****
 
Bins that have at least one sample will have a bar displayed. All leading and trailing empty bins are truncated. The final line will have a newline at the end.

Specified by:
toString in interface Histogram
Overrides:
toString in class Object
Returns:
the histogram

toString

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

Specified by:
toString in interface Histogram
Parameters:
binLabel - the label to append to each of the bins
Returns:
the 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