org.sapia.ubik.rmi.server.perf
Class Statistic

java.lang.Object
  extended by org.sapia.ubik.rmi.server.perf.Statistic
Direct Known Subclasses:
HitsPerSecStatistic

public class Statistic
extends java.lang.Object

This class models a statistic. A statistic can be incremented and provides an average over a given number of occurrences.

Author:
yduchesne

Constructor Summary
Statistic(java.lang.String name)
          Creates a statistic with a max count of 100 by default.
Statistic(java.lang.String name, int maxCount)
           
 
Method Summary
 java.lang.String getName()
           
 double getStat()
           
 double getValue()
           
 void incrementDouble(double inc)
           
 void incrementInt(int inc)
           
 void incrementLong(long inc)
          Adds the given long to this instance.
 boolean isEnabled()
           
protected  void onPostReset()
           
protected  void onPreReset()
           
 void reset()
           
 Statistic setEnabled(boolean enabled)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Statistic

public Statistic(java.lang.String name)
Creates a statistic with a max count of 100 by default.

See Also:
#Statistic(String, StatValue, int)

Statistic

public Statistic(java.lang.String name,
                 int maxCount)
Parameters:
name - the stat's name.
maxCount - the maximum number of occurrences over which averages are to be calculated. Once that number is reached, the value of the statistic is set to its current average, and the internal count is reset to 0.
Method Detail

setEnabled

public Statistic setEnabled(boolean enabled)
Parameters:
enabled - if true, stat calculation will be enabled.

isEnabled

public boolean isEnabled()
See Also:
setEnabled(boolean)

getName

public java.lang.String getName()
Returns:
this stat's name.

getValue

public double getValue()
Returns:
this stat's value.

incrementLong

public void incrementLong(long inc)
Adds the given long to this instance. Also internally increments the counter in order to calculate averages consistently.

Parameters:
inc - the long to use for the incrementation.

incrementDouble

public void incrementDouble(double inc)
See Also:
incrementLong(long)

incrementInt

public void incrementInt(int inc)
See Also:
incrementLong(long)

getStat

public double getStat()
Returns:
this instance's average, in one of the primitive wrappers (Integer, Long, Float, Double).

reset

public void reset()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

onPreReset

protected void onPreReset()

onPostReset

protected void onPostReset()


Copyright © 2010 Sapia OSS. All Rights Reserved.