blob: 74f4e46036937985f5e7505dad68f07438d6c2ea (
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
36
|
#pragma once
#include <inttypes.h>
#include <string>
#include "models/timer.hpp"
class FreqCounter {
public:
FreqCounter(FreqTimer const & timer)
: _timer(&timer)
{}
void reset() { _cnt = _overtime_cnt = 0; }
void inc();
uint32_t cnt() const { return _cnt; }
uint32_t overtime_cnt() const { return _overtime_cnt; }
[[nodiscard]] double rate() const;
[[nodiscard]] double overtime_rate() const;
[[nodiscard]] std::string display_value() const;
[[nodiscard]] std::string rate_display() const;
private:
uint32_t _cnt;
uint32_t _overtime_cnt;
FreqTimer const * _timer;
};
|