for_developers:timing_measurement
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
for_developers:timing_measurement [2016/08/15 16:43] – [Accuracy of the measurement] gehrig | for_developers:timing_measurement [2016/10/24 07:56] – [Explanation of the implementation] graf | ||
---|---|---|---|
Line 2: | Line 2: | ||
===== How the timer works ===== | ===== How the timer works ===== | ||
- | The timer function is included in the Executer object. It measures | + | The timer function is included in the Executer object. It registers |
+ | * run time: counter.tock() - counter.tick() | ||
+ | * period: counter.tick()[t=n] - counter.tick()[t=n-1] | ||
+ | * jitter: |actual period - set period| | ||
+ | Of these three measurements the minimal value, maximal value, mean value and the variance | ||
+ | |||
+ | Implementation in // | ||
+ | <code cpp> | ||
+ | ... | ||
+ | loop { | ||
+ | counter.tick(); | ||
+ | //code under test (list.run();) | ||
+ | counter.tock(); | ||
+ | } | ||
+ | ... | ||
+ | </ | ||
===== Influence of the measurement on the real time performance of the system ===== | ===== Influence of the measurement on the real time performance of the system ===== | ||
Line 14: | Line 29: | ||
===== Implementation ===== | ===== Implementation ===== | ||
- | To integrate the measurement, | + | To integrate the measurement, |
<code cpp> | <code cpp> | ||
using namespace eeros:: | using namespace eeros:: | ||
Line 20: | Line 35: | ||
- | eeros:: | + | eeros:: |
- | td.monitors.push_back([& | + | per.monitors.push_back([& |
static int ticks = 0; // mseconds | static int ticks = 0; // mseconds | ||
Line 29: | Line 44: | ||
// timing measurement (tictoc) | // timing measurement (tictoc) | ||
- | eeros::PeriodicCounter counter = c; | + | PeriodicCounter counter = c; |
c.reset(); | c.reset(); | ||
std::cout << "CS: period max: " << setw(7) | std::cout << "CS: period max: " << setw(7) | ||
Line 36: | Line 51: | ||
}); | }); | ||
- | eeros:: | + | eeros:: |
</ | </ | ||
- | ==== Explanation of the implementation ==== | + | If the executor has a small cycle time (less than 1 second) it is not advisable to update the log output each time. In the example the output is only updated after 1000 cycles. Depending on the cycle time, this number can be adjusted.\\ |
- | If the executor has a small cycle time (less than 1 second) it is not advisable to update the log output each time. In the implementation of the code example the output is only updated after 1000 cycles. Depending on the cycle time, this number can be adjusted | + | |
Line 7 defines which date should be written to the terminal output. Following options are available for //run// time and //period// time: | Line 7 defines which date should be written to the terminal output. Following options are available for //run// time and //period// time: |