AceUtils
0.2
Useful Arduino utilties which are too small for separate libraries.
|
25 #ifndef TIMING_STATS_TIMING_STATS_H
26 #define TIMING_STATS_TIMING_STATS_H
30 namespace timing_stats {
60 uint16_t
getMax()
const {
return mMax; }
63 uint16_t
getMin()
const {
return mMin; }
69 uint16_t
getAvg()
const {
return (mCount > 0) ? mSum / mCount : 0; }
87 if (duration < mMin) {
90 if (duration > mMax) {
94 mExpDecayAvg = (mCount > 0) ? (mExpDecayAvg + duration) / 2 : duration;
101 uint16_t mExpDecayAvg;
uint16_t getAvg() const
Return the average since the last reset().
void reset()
Reset the object to its initial state, except mCounter which is never reset.
uint16_t getExpDecayAvg() const
An exponential decay average since the last reset().
uint16_t getCounter() const
Number of times update() was called from the beginning of time.
TimingStats()
Constructor.
uint16_t getMin() const
Return the minium since the last reset().
uint16_t getCount() const
Number of times update() was called since last reset().
uint16_t getMax() const
Return the maximum since the last reset().
Helper class to collect timing statistics such as min, max, average, and exponential-decay average.
void update(uint16_t duration)
Add the given duration (often in milliseconds) to the statistics.