|
Click
|
An exponentially weighted moving average used to measure a rate. More...
#include <click/ewma.hh>
Inherits P.
Public Types | |
| typedef P::value_type | value_type |
| typedef P::signed_value_type | signed_value_type |
Public Member Functions | |
| RateEWMAX () | |
| Create a rate EWMA with initial value(s) 0. | |
| signed_value_type | scaled_average (unsigned ratenum=0) const |
| Return the current scaled moving average. | |
| unsigned | scale (unsigned ratenum=0) const |
| Returns one of the average's scaling factors (bits of fraction). | |
| int | rate (unsigned ratenum=0) const |
| Return the current rate in samples per second. | |
| void | update (signed_value_type delta, unsigned ratenum=0) |
| Update the sample count for the current epoch. | |
| String | unparse_rate (unsigned ratenum=0) const |
| Unparse the current average into a String. | |
An exponentially weighted moving average used to measure a rate.
The RateEWMAX template class represents an exponentially weighted moving average that measures a rate: a count of events per unit time. The average starts out with value 0.
RateEWMAX adds to DirectEWMAX a concept of epochs, which are periods of time. A RateEWMAX object collects samples over the current epoch. When the epoch closes, the collected sample count is used to update the moving average. Thus, the moving average is measured in samples per epoch. The rate() and unparse_rate() member functions return the rate in samples per second, rather than per epoch. These functions use the epoch frequency to translate between epochs and seconds.
Note that it often makes sense to call update() before calling scaled_average(), rate(), or unparse_rate(), in case an epoch or two has passed and the average should take account of passing time.
The template parameter P defines the EWMA parameters required by DirectEWMAX, and three others: a rate count, an epoch measurement, and an epoch frequency.
The rate count is the number of rates measured per object. Usually it is 1.
The epoch measurement is a function that returns the current epoch as an unsigned number. Epochs should increase monotonically.
The epoch frequency is the number of epochs per second, and is only used by rate() and unparse_rate().
These are defined by:
The rate count, as a static constant (for example, defined by an enum).
This function returns the current epoch number.
Since RateEWMAX inherits from an object of type P, these members are also directly available to callers.
The RateEWMAXParameters type is a good template argument for RateEWMAX.
|
inline |
Create a rate EWMA with initial value(s) 0.
|
inline |
Return the current scaled moving average.
| ratenum | rate index (0 <= ratenum < rate_count) |
|
inline |
Returns one of the average's scaling factors (bits of fraction).
|
inline |
Return the current rate in samples per second.
| ratenum | rate index (0 <= ratenum < rate_count) |
|
inline |
Update the sample count for the current epoch.
| delta | increment for current epoch sample count |
| ratenum | rate index (0 <= ratenum < rate_count) |
Unparse the current average into a String.
| ratenum | rate index (0 <= ratenum < rate_count) |