AceCommon
1.5.2
Arduino library for low-level common functions and features with no external dependencies
|
Helper class to collect timing statistics such as min, max, average, and exponential-decay average. More...
#include <GenericStats.h>
Public Member Functions | |
GenericStats () | |
Constructor. More... | |
GenericStats (const GenericStats &)=default | |
Default copy constructor. | |
GenericStats & | operator= (const GenericStats &)=default |
Default assignment operator. | |
void | reset () |
Reset the object to its initial state, except mCounter which is never reset. | |
T | getMax () const |
Return the maximum since the last reset(). | |
T | getMin () const |
Return the minium since the last reset(). | |
T | getAvg () const |
Return the average since the last reset(). More... | |
T | getExpDecayAvg () const |
An exponential decay average since the last reset(). | |
uint16_t | getCount () const |
Number of times update() was called since last reset(). | |
uint16_t | getCounter () const |
Number of times update() was called from the beginning of time. More... | |
void | update (T value) |
Add the given value to the statistics. | |
Helper class to collect timing statistics such as min, max, average, and exponential-decay average.
The internal sum
variable is also a type T
, so it is important to watch out for overflow of the sum
. Keeping the number of samples relatively small helps with preventing overflows.
See also TimingStats
which is the original version of this class, specialized to tracking a uint16_t
quantity.
T | type of the quantity being gathered (e.g. uint32_t or float) |
Definition at line 44 of file GenericStats.h.
|
inline |
|
inline |
Return the average since the last reset().
Returns 0 if update() has never been called.
Definition at line 82 of file GenericStats.h.
|
inline |
Number of times update() was called from the beginning of time.
Never reset. This is useful to determining how many times update() was called since it was last checked from the client code.
Definition at line 95 of file GenericStats.h.