RateMeter

class rate_meter.RateMeter(interval=1.0)[source]

This class allows to measure the rate of an iterative code. The rate value is calculated taking into account only the last interval seconds, so the measure can calculate the measured rate in real time.

__init__(interval=1.0)[source]

Returns a RateMeter instance.

Parameters:interval – Interval value for rate measurement, in seconds. Rate will be calculated over the last interval seconds.
rate()[source]

Calculates the rate over the last interval seconds.

Returns:Measured rate, or 0 if there is no data.
restart()[source]

Restarts this RateMeter instance, removing all stored data.

update(iter_num=None)[source]

Add a time reference for a new code iteration.

Parameters:iter_num – Current iteration number. If not set, the previous iteration count value increased by 1 will be taken.