File realtime_check.hpp¶
Tools for checking the real time of an algorithm.
- Author
Maximilien Naveau (maximilien.naveau@gmail.com) license License BSD-3-Clause
- Copyright
Copyright (c) 2019, New York University and Max Planck Gesellschaft.
- Date
2019-05-22
-
namespace
real_time_tools
-
class
RealTimeCheck
- #include <realtime_check.hpp>
super simple class for checking if thread ever lost realtime.
simply measure frequency between two calls to the tick function.
Public Functions
-
RealTimeCheck
(double target_frequency, double switch_frequency) Construct a new RealTimeCheck object.
- Parameters:
target_frequency – is the loop frequency.
switch_frequency – is the admissible frequency.
-
void
tick
() inform the instance of this class that an iteration passed
-
bool
was_realtime_lost
() const true if realtime was lost at least once (frequency between two ticks was below target frequencies)
-
bool
get_statistics
(int &ticks, int &switchs, double &target_frequency, double &switch_frequency, double &average_frequency, double ¤t_frequency, double &worse_frequency) return true if statistics are available, false otherwise (false is returned is tick has never been called or if ticks reached maximum integer value) switchs in the number of time realtime was lost.
-
double
get_average_frequency
() return the averaged observed frequency if statistics are available, -1 otherwise (false is returned is tick has never been called or if ticks reached maximum integer value).
-
double
get_current_frequency
() const returns observed frequency after last call to tick
-
void
print
() Display the results of the frequency measurement.
Private Members
-
bool
started
true if tick has been called once
-
std::chrono::high_resolution_clock::time_point
start_time
time at which tick was called first
-
std::chrono::high_resolution_clock::time_point
last_tick
last time system was ticked
-
double
target_frequency
frequency at which ticks are expected
-
double
epsilon
small quantity
-
uint
ticks
number of iterations
-
uint
switchs
number of time realtime was lost (target frequency not respected between two ticks)
-
double
average_frequency
average frequency
-
double
worse_frequency
worse frequency ever experienced
-
double
switch_frequency
nb of switches will increase by 1 each time measured frequency below this value
-
double
current_frequency
latest frequency that was measured
-
std::mutex
mutex
multithreading safety
-
-
class