Package network_monitor_udp :: Module linktest :: Class MetricLog
[frames] | no frames]

Class MetricLog

source code

Maintains a log of measurements for a variable. For each measurement, the time and value of the variable is recorded. Various statistics are computed for the recorded data.

Instance Methods
 
__init__(self) source code
 
reset_statistics(self)
Resets the aggregated statistics.
source code
 
reset_history(self)
Deletes all measurements recorded so far.
source code
 
reset_all(self)
Resets measurement log and statistics.
source code
 
record(self, measurement, meas_time=None)
Records a measurement.
source code
float
movavg(self, samples=MOVING_STATS_SAMPLES)
Returns the moving average of the recorded measurements.
source code
float
movstdev(self)
Returns the moving standard deviation of the recorded measurements.
source code
float
stdev(self)
Returns the standard deviation of the recorded measurements.
source code
boolean
empty(self)
Returns: True if the measurement log is empty
source code
float
min_time(self)
Returns the time of the first measurement recorded.
source code
float
max_time(self)
Returns the time of the last measurement recorded.
source code
float
duration(self)
Returns the period during which measurements where made (the time elapsed from the first to the last measurement).
source code
float
min(self)
Returns: minimum value in the log
source code
float
max(self)
Returns: maximum value in the log
source code
float
avg(self)
Returns: the mean of the values in the log
source code
float
expavg(self)
Returns: the exponential average of the values in the log
source code
float
count(self)
Returns: the number of values in the log
source code
float
curr(self)
Returns: the last value recorded
source code
[(float, float)]
history(self)
Returns: the list of measurements recorded.
source code
Class Variables
  ALPHA = 0.1
the alpha-parameter of the exponential average
  MOVING_STATS_SAMPLES = 10
default number of samples included in moving stats
Method Details

record(self, measurement, meas_time=None)

source code 

Records a measurement.

Parameters:
  • measurement (float) - the value being recorded
  • meas_time (float) - the time of the measurement (if not specified the current time as retrieved by time.time() will be used)

movavg(self, samples=MOVING_STATS_SAMPLES)

source code 

Returns the moving average of the recorded measurements.

Parameters:
  • samples (int) - the number of samples in the moving average
Returns: float
moving average

movstdev(self)

source code 

Returns the moving standard deviation of the recorded measurements.

Parameters:
  • samples (int) - the number of samples in the moving standard deviation
Returns: float
moving standard deviation

stdev(self)

source code 

Returns the standard deviation of the recorded measurements.

Returns: float
standard deviation

empty(self)

source code 
Returns: boolean
True if the measurement log is empty

min_time(self)

source code 

Returns the time of the first measurement recorded.

Returns: float
First measurement time or 0.0 if the log is empty.

max_time(self)

source code 

Returns the time of the last measurement recorded.

Returns: float
Last measurement time or 0.0 if the log is empty.

duration(self)

source code 

Returns the period during which measurements where made (the time elapsed from the first to the last measurement).

Returns: float
duration in seconds

min(self)

source code 
Returns: float
minimum value in the log

max(self)

source code 
Returns: float
maximum value in the log

avg(self)

source code 
Returns: float
the mean of the values in the log

expavg(self)

source code 
Returns: float
the exponential average of the values in the log

count(self)

source code 
Returns: float
the number of values in the log

curr(self)

source code 
Returns: float
the last value recorded

history(self)

source code 
Returns: [(float, float)]
the list of measurements recorded. Each measurement is a tuple (value, measurement_time).