#include <MonitoredQuantity.hh>
Classes | |
struct | Stats |
Public Types | |
enum | DataSetType { FULL = 0, RECENT = 1 } |
typedef double | DURATION_T |
typedef double | TIME_POINT_T |
Public Member Functions | |
MonitoredQuantity (DURATION_T expectedCalculationInterval, DURATION_T timeWindowForRecentResults) | |
void | addSample (const double value=1.0) |
void | addSample (const int value=1) |
void | addSample (const uint32_t value=1) |
void | addSample (const uint64_t value=1) |
bool | calculateStatistics (TIME_POINT_T currentTime=getCurrentTime()) |
void | reset () |
void | enable () |
void | disable () |
bool | isEnabled () const |
void | setNewTimeWindowForRecentResults (DURATION_T interval) |
DURATION_T | getTimeWindowForRecentResults () const |
DURATION_T | ExpectedCalculationInterval () const |
bool | waitUntilAccumulatorsHaveBeenFlushed (DURATION_T timeout) const |
void | getStats (Stats &stats) const |
TIME_POINT_T | lastCalculationTime () const |
DURATION_T | fullDuration () const |
double | recentValueSum () const |
double | recentValueAverage () const |
long long | fullSampleCount () const |
Static Public Member Functions | |
static TIME_POINT_T | getCurrentTime () |
This class keeps track of statistics for a set of sample values and provides timing information on the samples.
Definition at line 21 of file MonitoredQuantity.hh.
void MonitoredQuantity::addSample | ( | const double | value = 1.0 | ) |
Adds the specified doubled valued sample value to the monitor instance.
Definition at line 19 of file MonitoredQuantity.cc.
void MonitoredQuantity::addSample | ( | const int | value = 1 | ) |
Adds the specified integer valued sample value to the monitor instance.
Definition at line 34 of file MonitoredQuantity.cc.
void MonitoredQuantity::addSample | ( | const uint32_t | value = 1 | ) |
Adds the specified uint32_t valued sample value to the monitor instance.
Definition at line 39 of file MonitoredQuantity.cc.
void MonitoredQuantity::addSample | ( | const uint64_t | value = 1 | ) |
Adds the specified uint64_t valued sample value to the monitor instance.
Definition at line 44 of file MonitoredQuantity.cc.
bool MonitoredQuantity::calculateStatistics | ( | TIME_POINT_T | currentTime = getCurrentTime() | ) |
Forces a calculation of the statistics for the monitored quantity. The frequency of the updates to the statistics is driven by how often this method is called. It is expected that this method will be called once per interval specified by expectedCalculationInterval
Definition at line 49 of file MonitoredQuantity.cc.
void MonitoredQuantity::disable | ( | ) |
Disables the monitor.
Definition at line 253 of file MonitoredQuantity.cc.
void MonitoredQuantity::enable | ( | ) |
Enables the monitor (and resets the statistics to provide a fresh start).
Definition at line 245 of file MonitoredQuantity.cc.
|
static |
Returns the current point in time. A negative value indicates that an error occurred when fetching the time from the operating system.
Definition at line 357 of file MonitoredQuantity.cc.
void MonitoredQuantity::getStats | ( | Stats & | stats | ) | const |
Write all our collected statistics into the given Stats struct.
Definition at line 315 of file MonitoredQuantity.cc.
|
inline |
Returns the length of the time window that has been specified for recent results. (This may be different than the actual length of the recent time window which is affected by the interval of calls to the calculateStatistics() method. Use a getDuration(RECENT) call to determine the actual recent time window.)
Definition at line 105 of file MonitoredQuantity.hh.
|
inline |
Tests whether the monitor is currently enabled.
Definition at line 89 of file MonitoredQuantity.hh.
void MonitoredQuantity::reset | ( | ) |
Resets the monitor (zeroes out all counters and restarts the time interval).
Definition at line 233 of file MonitoredQuantity.cc.
void MonitoredQuantity::setNewTimeWindowForRecentResults | ( | DURATION_T | interval | ) |
Specifies a new time interval to be used when calculating "recent" statistics.
Definition at line 260 of file MonitoredQuantity.cc.