Package DebTorrent :: Module CurrentRateMeasure :: Class Measure
[hide private]
[frames] | no frames]

Class Measure

source code

The measurement of one rate.

Instance Methods [hide private]
 
__init__(self, max_rate_period, fudge=1)
Initialize the measurement.
source code
call graph 
 
update_rate(self, amount)
Update the rate with new data.
source code
call graph 
float
get_rate(self)
Get the current rate measurement.
source code
float
get_rate_noupdate(self)
Get the current rate measurement without updating it.
source code
float
time_until_rate(self, newrate)
Calculate how long until the rate drops to the target.
source code
float
get_total(self)
Get the total amount used to calculate the rate..
source code
Instance Variables [hide private]
float last
the last time the rate was updated
float max_rate_period
maximum amount of time to guess the current rate estimate represents
float rate
the latest calculated rate
float ratesince
the oldest time the rate estimate is for
long total
the total amount that went in to calculating the rate
Method Details [hide private]

__init__(self, max_rate_period, fudge=1)
(Constructor)

source code 
call graph 
Initialize the measurement.
Parameters:
  • max_rate_period (float) - maximum amount of time to guess the current rate estimate represents
  • fudge (int) - time equivalent of writing to kernel-level TCP buffer, for rate adjustment (optional, defaults to 1)

update_rate(self, amount)

source code 
call graph 
Update the rate with new data.
Parameters:
  • amount (long) - the new data to add into the rate calculation

get_rate(self)

source code 
Get the current rate measurement.
Returns: float
the current rate

get_rate_noupdate(self)

source code 
Get the current rate measurement without updating it.
Returns: float
the current rate

time_until_rate(self, newrate)

source code 
Calculate how long until the rate drops to the target.
Parameters:
  • newrate (float) - the target rate
Returns: float
the number of seconds until the rate decreases to the target rate, or 0 if it's already there (or below it)

get_total(self)

source code 
Get the total amount used to calculate the rate..
Returns: float
the total amount