net.bonzoun.cocodonkey
Class RateCalculator

java.lang.Object
  extended bynet.bonzoun.cocodonkey.RateCalculator

public class RateCalculator
extends java.lang.Object

This class is intended to calculate a remaining time for a download. For that, it uses instant download rates and makes complicated averages on them to finally get a better approximation of the remaining time than what the instant download rate can give. A first calculation is done with a floating average of the rate on a one minute length (MINUTE_LENGTH*MINUTE_PRECISION gives the length of a minute for the calculation, the unite being the second). A second estimation uses a one hour length for the floating average (one hour is HOUR_LENGTH*HOUR_PRECISION long, the unite being the second). The best of these two calculations is supposed to be the best bet for the current rate. The addRate() method is used to add a rate. It can be called as often as possible as the current class only uses the required data (MINUTE_PRECISION determines the amount of data that will be retained).


Nested Class Summary
(package private)  class RateCalculator.RateKeeper
           
 
Constructor Summary
RateCalculator()
           
 
Method Summary
 void addRate(float rate)
           
 float meanRate()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RateCalculator

public RateCalculator()
Method Detail

addRate

public void addRate(float rate)

meanRate

public float meanRate()