21#include "kanoopcommon.h"
34 _evaluationMsecs(1000) {}
41 _evaluationMsecs(evaluationMsecs) {}
61 QVariant
data()
const {
return _data; }
67 void setData(QVariant value) { _data = value; }
89 RateEvent(quint64 timestamp, qint64 count) :
90 _timestamp(timestamp),
97 void pruneOldEvents(qint64 now);
99 int _evaluationMsecs = 1000;
102 QList<RateEvent> _events;
104 qint64 _lastPruneTime = 0;
105 static const qint64 PruneIntervalMsecs = 1000;
RateMonitor()
Construct a RateMonitor with a default 1-second evaluation window.
double eventsPerSecond()
Compute the current event rate over the evaluation window.
QVariant data() const
Return the arbitrary data payload attached to this monitor.
void setEvaluationTime(int msecs)
Set the evaluation window duration.
void setData(QVariant value)
Attach arbitrary data to this monitor for caller use.
RateMonitor(int evaluationMsecs)
Construct a RateMonitor with a custom evaluation window.
int evaluationMsecs() const
Return the evaluation window duration in milliseconds.
void addEvent(int count=1)
Record one or more occurrences of the monitored event.