artdaq_core
v3_04_09
|
This class keeps track of statistics for a set of sample values and provides timing information on the samples. More...
#include <artdaq-core/Core/MonitoredQuantity.hh>
Public Member Functions | |
MonitoredQuantity (DURATION_T expectedCalculationInterval, DURATION_T timeWindowForRecentResults) | |
Instantiates a MonitoredQuantity object. More... | |
void | addSample (const double value=1.0) |
Adds the specified doubled valued sample value to the monitor instance. More... | |
void | addSample (const int value=1) |
Adds the specified integer valued sample value to the monitor instance. More... | |
void | addSample (const uint32_t value=1) |
Adds the specified uint32_t valued sample value to the monitor instance. More... | |
void | addSample (const uint64_t value=1) |
Adds the specified uint64_t valued sample value to the monitor instance. More... | |
bool | calculateStatistics (TIME_POINT_T currentTime=getCurrentTime()) |
Forces a calculation of the statistics for the monitored quantity. More... | |
void | reset () |
void | enable () |
void | disable () |
bool | isEnabled () const |
Tests whether the monitor is currently enabled. More... | |
void | setNewTimeWindowForRecentResults (DURATION_T interval) |
Specifies a new time interval to be used when calculating "recent" statistics. More... | |
DURATION_T | getTimeWindowForRecentResults () const |
Returns the length of the time window that has been specified for recent results. More... | |
DURATION_T | ExpectedCalculationInterval () const |
Returns the expected interval between calculateStatistics calls. More... | |
bool | waitUntilAccumulatorsHaveBeenFlushed (DURATION_T timeout) const |
Blocks while the MonitoredQuantity is flushed, up to timeout duration. More... | |
void | getStats (MonitoredQuantityStats &stats) const |
Write all our collected statistics into the given Stats struct. More... | |
TIME_POINT_T | getLastCalculationTime () const |
Access the last calculation time. | |
DURATION_T | getFullDuration () const |
Access the full duration of the statistics. | |
double | getRecentValueSum () const |
Access the sum of the value samples in the "recent" time span. | |
double | getRecentValueAverage () const |
Access the average of the value samples in the "recent" time span. | |
long long | getFullSampleCount () const |
Access the count of samples for the entire history of the MonitoredQuantity. | |
Static Public Member Functions | |
static TIME_POINT_T | getCurrentTime () |
Returns the current point in time. More... | |
This class keeps track of statistics for a set of sample values and provides timing information on the samples.
Definition at line 158 of file MonitoredQuantity.hh.
|
explicit |
Instantiates a MonitoredQuantity object.
expectedCalculationInterval | How often calculateStatistics is expected to be called |
timeWindowForRecentResults | Defines the meaning of DataSetType::RECENT |
Definition at line 9 of file MonitoredQuantity.cc.
void MonitoredQuantity::addSample | ( | const double | value = 1.0 | ) |
Adds the specified doubled valued sample value to the monitor instance.
value | The sample value to add |
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.
value | The sample value to add |
Definition at line 35 of file MonitoredQuantity.cc.
void MonitoredQuantity::addSample | ( | const uint32_t | value = 1 | ) |
Adds the specified uint32_t valued sample value to the monitor instance.
value | The sample value to add |
Definition at line 40 of file MonitoredQuantity.cc.
void MonitoredQuantity::addSample | ( | const uint64_t | value = 1 | ) |
Adds the specified uint64_t valued sample value to the monitor instance.
value | The sample value to add |
Definition at line 45 of file MonitoredQuantity.cc.
bool MonitoredQuantity::calculateStatistics | ( | TIME_POINT_T | currentTime = getCurrentTime() | ) |
Forces a calculation of the statistics for the monitored quantity.
currentTime | Time point to use for calculating statistics (if synchronized at a higher level) |
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 50 of file MonitoredQuantity.cc.
void MonitoredQuantity::disable | ( | ) |
Disables the monitor.
Definition at line 274 of file MonitoredQuantity.cc.
void MonitoredQuantity::enable | ( | ) |
Enables the monitor (and resets the statistics to provide a fresh start).
Definition at line 265 of file MonitoredQuantity.cc.
|
inline |
Returns the expected interval between calculateStatistics calls.
Definition at line 259 of file MonitoredQuantity.hh.
|
static |
Returns the current point in time.
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 381 of file MonitoredQuantity.cc.
void MonitoredQuantity::getStats | ( | MonitoredQuantityStats & | stats | ) | const |
Write all our collected statistics into the given Stats struct.
stats | Destination for copy of collected statistics |
Definition at line 338 of file MonitoredQuantity.cc.
|
inline |
Returns the length of the time window that has been specified for recent results.
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 250 of file MonitoredQuantity.hh.
|
inline |
Tests whether the monitor is currently enabled.
Definition at line 230 of file MonitoredQuantity.hh.
void MonitoredQuantity::reset | ( | ) |
Resets the monitor (zeroes out all counters and restarts the time interval).
Definition at line 253 of file MonitoredQuantity.cc.
void MonitoredQuantity::setNewTimeWindowForRecentResults | ( | DURATION_T | interval | ) |
Specifies a new time interval to be used when calculating "recent" statistics.
interval | The new time interval for calculating "recent" statistics. |
Definition at line 281 of file MonitoredQuantity.cc.
bool MonitoredQuantity::waitUntilAccumulatorsHaveBeenFlushed | ( | DURATION_T | timeout | ) | const |
Blocks while the MonitoredQuantity is flushed, up to timeout duration.
timeout | How long to wait for the MonitoredQuantity to be emptied, in seconds |
Definition at line 318 of file MonitoredQuantity.cc.