blob: 4855c24e6621f619759508de38f91553983636be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#include "models/counter.hpp"
double FreqCounter::rate() const {
uint64_t ms = _timer->total_duration_ms();
if(_timer->overtime()) {
ms = _timer->preset_ms();
}
return static_cast<double>(_cnt) / (ms / 60.0e3);
}
double FreqCounter::overtime_rate() const {
return static_cast<double>(_overtime_cnt) / (_timer->total_duration_ms() / 60.0e3);
}
std::string FreqCounter::display_value() const {
if(_cnt == UINT32_MAX) {
return "ERR";
}
return std::to_string(_cnt);
}
void FreqCounter::inc() {
if(_overtime_cnt != UINT32_MAX)
_overtime_cnt++;
if(!_timer->overtime()) {
_cnt = _overtime_cnt;
}
}
|