KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
Loading...
Searching...
No Matches
RateMonitor Class Reference

RateMonitor. More...

#include <ratemonitor.h>

Public Slots

void addEvent (int count=1)
 Record one or more occurrences of the monitored event.
 

Public Member Functions

 RateMonitor ()
 Construct a RateMonitor with a default 1-second evaluation window.
 
 RateMonitor (int evaluationMsecs)
 Construct a RateMonitor with a custom 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 setData (QVariant value)
 Attach arbitrary data to this monitor for caller use.
 
int evaluationMsecs () const
 Return the evaluation window duration in milliseconds.
 
void setEvaluationTime (int msecs)
 Set the evaluation window duration.
 

Detailed Description

RateMonitor.

Calculate the rate at which something is happening (e.g. packets-per-second)

Every time the thing happens, call addEvent().

Use eventsPerSecond() to obtain the actual rate.

setEvaluationTime() sets the sliding time window over which the calculation is performed.

Stephen Punak, July 08 2019

Tracks event counts over a sliding time window to compute a real-time rate.

Call addEvent() each time the measured event occurs. Use eventsPerSecond() to retrieve the computed rate over the configured evaluation window.

Definition at line 29 of file ratemonitor.h.

Constructor & Destructor Documentation

◆ RateMonitor() [1/2]

RateMonitor::RateMonitor ( )
inline

Construct a RateMonitor with a default 1-second evaluation window.

Definition at line 33 of file ratemonitor.h.

◆ RateMonitor() [2/2]

RateMonitor::RateMonitor ( int  evaluationMsecs)
inline

Construct a RateMonitor with a custom evaluation window.

Parameters
evaluationMsecsSliding window duration in milliseconds

Definition at line 40 of file ratemonitor.h.

Member Function Documentation

◆ addEvent

void RateMonitor::addEvent ( int  count = 1)
slot

Record one or more occurrences of the monitored event.

Parameters
countNumber of events to record (default 1)

◆ data()

QVariant RateMonitor::data ( ) const
inline

Return the arbitrary data payload attached to this monitor.

Returns
Stored QVariant data

Definition at line 61 of file ratemonitor.h.

◆ evaluationMsecs()

int RateMonitor::evaluationMsecs ( ) const
inline

Return the evaluation window duration in milliseconds.

Returns
Evaluation window in milliseconds

Definition at line 73 of file ratemonitor.h.

◆ eventsPerSecond()

double RateMonitor::eventsPerSecond ( )

Compute the current event rate over the evaluation window.

Returns
Number of events per second

◆ setData()

void RateMonitor::setData ( QVariant  value)
inline

Attach arbitrary data to this monitor for caller use.

Parameters
valueData to store

Definition at line 67 of file ratemonitor.h.

◆ setEvaluationTime()

void RateMonitor::setEvaluationTime ( int  msecs)
inline

Set the evaluation window duration.

Parameters
msecsNew window duration in milliseconds

Definition at line 79 of file ratemonitor.h.


The documentation for this class was generated from the following file: