Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

ro.nolimits.rue.util
Class OperationPerTimeCounter  view OperationPerTimeCounter download OperationPerTimeCounter.java

java.lang.Object
  extended byro.nolimits.rue.util.OperationPerTimeCounter
All Implemented Interfaces:
java.io.Serializable

public class OperationPerTimeCounter
extends java.lang.Object
implements java.io.Serializable

Used to calculate number of operations occurred during a time interval. Was builded for working with cumulative values, so we only have to pass the current value to the hit method.

Basically we can use the two methods to get valuable results. the getCount for counting the number of times hit was called during the specified amount of time and getOperationsNumber to know how much the cumulative counter has been incremented during the same specified amount of time.

Version:
$Revision: 0.5.1.1 $ $Date: 2000/08/01 10:52:40 $

Field Summary
private  java.util.Vector _fifo
           
private  long _timePeriod
          The time (in ms) durring which a hit will be considered as active
private  java.util.Vector _value
           
 
Constructor Summary
OperationPerTimeCounter()
          Default constructor
OperationPerTimeCounter(long time_int)
          Constructs an counter whitch will count operations number during the time interval specified
 
Method Summary
private  void cleanFIFO(long curr_time)
          That's the way we count hits, we put the time of the hit in a fifo then we only have to care to keep in the fifo only the values which are in our time interval.
 long getCount()
          Returns the number of hits occured during the last x milliseconds specified with setTimeInterval
 float getOperationsNumber()
          Returns the number of operations during the specified amount of time.
 long getTimeInterval()
          With this method we can set the time interval used for counting hits
 void hit(float hits)
          The main method, we will call this to pass in values related to the cumulative value we track.
 void setTimeInterval(long time_int)
          With this method we can set the time interval used for counting hits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_timePeriod

private long _timePeriod
The time (in ms) durring which a hit will be considered as active


_fifo

private java.util.Vector _fifo

_value

private java.util.Vector _value
Constructor Detail

OperationPerTimeCounter

public OperationPerTimeCounter()
Default constructor


OperationPerTimeCounter

public OperationPerTimeCounter(long time_int)
Constructs an counter whitch will count operations number during the time interval specified

Method Detail

setTimeInterval

public void setTimeInterval(long time_int)
With this method we can set the time interval used for counting hits


cleanFIFO

private void cleanFIFO(long curr_time)
That's the way we count hits, we put the time of the hit in a fifo then we only have to care to keep in the fifo only the values which are in our time interval. We would only have to call this when a getCount is received, but in for not getting too big without reasons we will call it also in hit()


getTimeInterval

public long getTimeInterval()
With this method we can set the time interval used for counting hits


hit

public void hit(float hits)
The main method, we will call this to pass in values related to the cumulative value we track.


getCount

public long getCount()
Returns the number of hits occured during the last x milliseconds specified with setTimeInterval


getOperationsNumber

public float getOperationsNumber()
Returns the number of operations during the specified amount of time.