ifw-fnd 2.0.1
 
Loading...
Searching...
No Matches
tools.hpp
Go to the documentation of this file.
1
7
8#pragma once
9
10#include <array>
11#include <execinfo.h>
12#include <iomanip>
13#include <iostream>
14#include <string>
15#include <thread>
16#include <vector>
17#include <queue>
18
19#include <fmt/format.h>
20
22#include <ifw/fnd/defs/base.hpp>
23
24
25namespace ifw::fnd::tools {
26
27 // GetLoggersAsStrList(): removed during the log4cplus migration.
28 //
29 // The previous implementation iterated log4cplus's process-wide logger
30 // registry. With the abstract ifw::fnd::Logger model there is exactly
31 // ONE installed logger per process; there is no registry to enumerate,
32 // so the function lost its meaning. If a downstream component needs to
33 // expose information about the installed logger, it can implement a
34 // small accessor on its own Logger subclass.
35
38 public:
44 explicit LoopFrequencyCalculator(size_t window_size = 100);
45
46 void SetWindowSize(const size_t window_size);
47
48 // Method to mark the current time (called at each loop iteration)
49 void Tick();
50
51 // Method to get the current calculated frequency in Hz
52 double GetFrequency() const;
53
54 // Reset internal buffers to start over measurement.
55 void Reset();
56
57 private:
58 size_t m_window_size; // Number of samples in the window
59 std::queue<std::chrono::high_resolution_clock::time_point> m_timestamps; // Timestamps queue
60 std::queue<long long> m_durations; // Durations queue (in milliseconds)
61 long long m_sum_durations; // Sum of the durations in the current window
62 };
63}
void Reset()
Definition tools.cpp:46
double GetFrequency() const
Definition tools.cpp:38
void SetWindowSize(const size_t window_size)
Definition tools.cpp:14
LoopFrequencyCalculator(size_t window_size=100)
Definition tools.cpp:11
void Tick()
Definition tools.cpp:19
ifw-fnd logging abstraction.
Header file for the IFW Foundation Tools library.
Definition tools.hpp:25