tools:monitor:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tools:monitor:start [2018/05/31 11:59] – [Changing] graf | tools:monitor:start [2020/08/12 10:02] (current) – [Measuring a Single Block] ursgraf | ||
---|---|---|---|
Line 2: | Line 2: | ||
It is often desirable to determine whether realtime performance criteria are met or how long a certain time domain takes to run. For this purpose each time domain as well as the safety system comprises of a dedicated timer. | It is often desirable to determine whether realtime performance criteria are met or how long a certain time domain takes to run. For this purpose each time domain as well as the safety system comprises of a dedicated timer. | ||
===== How the Timer Works ===== | ===== How the Timer Works ===== | ||
- | The timer function | + | The timer is implemented in '' |
* run time: tock() - tick() | * run time: tock() - tick() | ||
* period: tick()[t=n] - tick()[t=n-1] | * period: tick()[t=n] - tick()[t=n-1] | ||
Line 19: | Line 19: | ||
===== How to use the Timer ===== | ===== How to use the Timer ===== | ||
- | The timer measurements can be used to monitor execution timing and notably realtime performance. After the creation of a periodic task, a monitor function can be added before the task is added to the '' | + | The timer measurements can be used to monitor execution timing and notably realtime performance. After the creation of a periodic task, a monitor function can be added before the task is added to the '' |
+ | IMPORTANT Add the monitor function before adding the periodic task to the executor. | ||
<code cpp> | <code cpp> | ||
eeros:: | eeros:: | ||
// the periodic will run a given time domain | // the periodic will run a given time domain | ||
- | periodic.monitors.push_back([& | + | periodic.monitors.push_back([& |
log.info() << " | log.info() << " | ||
}); | }); | ||
Line 69: | Line 70: | ||
===== Using the Timer to Change Safety Levels ===== | ===== Using the Timer to Change Safety Levels ===== | ||
- | For a certain type of safety critical robots, it is desirable to change into a safe level in case of the jitter in periodicity of a time domain or the safety system itself | + | For a certain type of safety critical robots, it is desirable to change into a safe level in case of the jitter in periodicity of a time domain or the safety system itself |
<code cpp> | <code cpp> | ||
- | eeros:: | ||
- | eeros:: | ||
- | |||
periodic.monitors.push_back([=](PeriodicCounter &c, Logger< | periodic.monitors.push_back([=](PeriodicCounter &c, Logger< | ||
if (c.period.max >= dt) safetySystem.triggerEvent(myEvent); | if (c.period.max >= dt) safetySystem.triggerEvent(myEvent); | ||
}); | }); | ||
- | |||
- | eeros:: | ||
</ | </ | ||
- | Make sure to add the periodic to the executor. Usually you add the timedomain to the executor and its associated periodic is generated internally. However, in this case, we have to declare the periodic explicitely in order to be able to assign the monitor function. | + | |
===== Accuracy of the Measurement ===== | ===== Accuracy of the Measurement ===== | ||
Line 94: | Line 90: | ||
With this command it is possible to measure for multiple hours or even multiple days. | With this command it is possible to measure for multiple hours or even multiple days. | ||
- | executor.getMainTask()-> | + | ===== Measuring a Single Block ===== |
- | static int ticks = 0; | + | Especially when implementing your own blocks one wishes to measure the time it takes to run it. This can be very useful for blocks with complex algorithms or in cases your timedomain with many blocks takes to much time to run and you want to pinpoint the culprit. For this purpose add a '' |
- | if (++ticks < 200) return; | + | <code cpp> |
- | ticks = 0; | + | # |
- | log.warn() << "ss: period max: " << c.period.max | + | |
- | c.reset(); | + | eeros:: |
- | }); | + | |
+ | virtual void run() { | ||
+ | pc.tick(); | ||
+ | ... // algorithm | ||
+ | pc.tock(); | ||
+ | </ | ||
+ | You can then periodically print the mean and maximum run time. |
tools/monitor/start.1527760747.txt.gz · Last modified: 2018/05/31 11:59 (external edit)