This class implements a calculate for rates like frame rates.
More...
#include <RateCalculator.h>
|
| | RateCalculator (const double window=1.0) |
| | Creates a new rate calculator object.
|
| |
| void | addOccurence (const Timestamp ×tamp, const double quantity=1.0) |
| | Adds another occurrence (e.g., a new frame has been processed).
|
| |
| double | rate (const Timestamp ×tamp) const |
| | Returns the current rate.
|
| |
| bool | rateEveryNSeconds (const Timestamp &rateTimestamp, double &rate, const double interval=1.0, const Timestamp &requestTimestamp=Timestamp(false)) |
| | Returns the current rate only every n-th second.
|
| |
| void | setWindow (const double window) |
| | Updates the window of this rate calculator.
|
| |
| double | window () const |
| | Returns the window of this rate calculator.
|
| |
| void | clear () |
| | Clears the rate calculator e.g., to start with a completely new measurement.
|
| |
|
| using | TimestampMap = std::map< Timestamp, double > |
| | Definition of an ordered map mapping timestamps to quantities.
|
| |
This class implements a calculate for rates like frame rates.
The rates are determined with a sliding windows.
The class is thread-safe.
◆ TimestampMap
Definition of an ordered map mapping timestamps to quantities.
◆ RateCalculator()
| Ocean::RateCalculator::RateCalculator |
( |
const double |
window = 1.0 | ) |
|
|
inlineexplicit |
Creates a new rate calculator object.
- Parameters
-
| window | The size of the sliding window, in seconds, with range (0, infinity) |
◆ addOccurence()
| void Ocean::RateCalculator::addOccurence |
( |
const Timestamp & |
timestamp, |
|
|
const double |
quantity = 1.0 |
|
) |
| |
Adds another occurrence (e.g., a new frame has been processed).
- Parameters
-
| timestamp | The timestamp at which the occurrence happened, must be valid |
| quantity | The quantity of the current occurrence |
◆ clear()
| void Ocean::RateCalculator::clear |
( |
| ) |
|
|
inline |
Clears the rate calculator e.g., to start with a completely new measurement.
◆ rate()
| double Ocean::RateCalculator::rate |
( |
const Timestamp & |
timestamp | ) |
const |
Returns the current rate.
- Parameters
-
| timestamp | The timestamp at which the current rate will be determined, must be valid |
- Returns
- The current rate, with range [0, infinity)
◆ rateEveryNSeconds()
| bool Ocean::RateCalculator::rateEveryNSeconds |
( |
const Timestamp & |
rateTimestamp, |
|
|
double & |
rate, |
|
|
const double |
interval = 1.0, |
|
|
const Timestamp & |
requestTimestamp = Timestamp(false) |
|
) |
| |
Returns the current rate only every n-th second.
- Parameters
-
| rateTimestamp | The timestamp at which the current rate will be determined, must be valid |
| rate | The resulting current rate, with range [0, infinity) |
| interval | The number of seconds necessary since the last successful call of this function, with range [0, infinity) |
| requestTimestamp | Optional an explicit timestamp when the request happens, e.g., in display time, invalid to use the timestamp for the rate |
- Returns
- True, if the rate was determined; False, if the interval was not yet reached
◆ setWindow()
| void Ocean::RateCalculator::setWindow |
( |
const double |
window | ) |
|
|
inline |
Updates the window of this rate calculator.
- Parameters
-
| window | The window to be set, in seconds, with range [0, infinity) |
◆ window()
| double Ocean::RateCalculator::window |
( |
| ) |
const |
|
inline |
Returns the window of this rate calculator.
- Returns
- The rate calculator's window, in seconds, with range [0, infinity)
◆ lastRequestTimestamp_
| Timestamp Ocean::RateCalculator::lastRequestTimestamp_ |
|
protected |
The timestamp at which the rate has been sucessfully requested the last time when calling rateEveryNSeconds().
◆ lock_
| Lock Ocean::RateCalculator::lock_ |
|
mutableprotected |
◆ timestampMap_
The map mapping timestamps to quantities.
◆ window_
| double Ocean::RateCalculator::window_ = 1.0 |
|
protected |
The size of the sliding window, in seconds, with range (0, infinity).
The documentation for this class was generated from the following file: