12#ifndef RTCTK_COMPONENTFRAMEWORK_FREQUENCYESTIMATOR_HPP
13#define RTCTK_COMPONENTFRAMEWORK_FREQUENCYESTIMATOR_HPP
30template <
typename ClockType = std::chrono::steady_clock>
41 const std::string&
desc,
42 const std::string&
prefix =
"")
43 : m_num_samples(0), m_start_time(ClockType::now()), m_frequency_estimate(0) {
46 path =
"frequency_estimate";
48 path =
prefix +
"/frequency_estimate";
52 m_frequency_estimate_reg =
56 "FrequencyEstimator: Failed to register to metrics service. "
57 "Will ignore and continue anyway: "
71 using namespace std::chrono_literals;
78 m_frequency_estimate.Store(m_num_samples /
elapsed_time.count());
92 return m_frequency_estimate.Load();
101 m_frequency_estimate.Store(0);
102 m_start_time = ClockType::now();
108 typename ClockType::time_point m_start_time;
110 perfc::CounterDouble m_frequency_estimate;
111 perfc::ScopedRegistration m_frequency_estimate_reg;
Component metrics interface.
Definition componentMetricsIf.hpp:85
Defines auxiliary information associated with each counter registered with ComponentMetricsIf.
Definition componentMetricsIf.hpp:46
Estimates the frequency in which Tick is called and publishes result to OLDB.
Definition frequencyEstimator.hpp:31
FrequencyEstimator(ComponentMetricsIf &metrics, const std::string &desc, const std::string &prefix="")
Construct instance.
Definition frequencyEstimator.hpp:40
double GetValue() const
Method to get the measured frequency in Hz.
Definition frequencyEstimator.hpp:91
void Reset()
Method to reset the estimator.
Definition frequencyEstimator.hpp:100
void Tick() noexcept
Method to be called repeatedly from within the hot loop that should be measured.
Definition frequencyEstimator.hpp:70
Adapter object intended to be used in contexts without direct access to the output-stream object.
Definition exceptions.hpp:159
Header file for ComponentMetricsIf.
Logging Support Library based on log4cplus.
Definition commandReplier.cpp:22
log4cplus::Logger & GetLogger(const std::string &name="app")
Get handle to a specific logger.
Definition logger.cpp:193
elt::mal::future< std::string > InjectReqRepEvent(StateMachineEngine &engine)
Definition malEventInjector.hpp:23