User Tools

Site Tools


tools:monitor:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
tools:monitor:start [2020/08/12 09:59] – [How the Timer Works] ursgraftools:monitor:start [2020/08/12 10:02] (current) – [Measuring a Single Block] ursgraf
Line 93: Line 93:
 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 ''PeriodicCounter'' to the block and add //tick()// and //tock()// to its run method. 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 ''PeriodicCounter'' to the block and add //tick()// and //tock()// to its run method.
 <code cpp> <code cpp>
 +#include <eeros/core/PeriodicCounter.hpp>   // add include file
 +
 +eeros::PeriodicCounter pc;                  // add periodic counter object to your block
 +
 virtual void run() { virtual void run() {
-  pc.tick();+  pc.tick();                                // start ...
   ... // algorithm   ... // algorithm
-  pc.tock();+  pc.tock();                                // ... and stop the timer
 </code>  </code> 
 You can then periodically print the mean and maximum run time. You can then periodically print the mean and maximum run time.
tools/monitor/start.txt · Last modified: 2020/08/12 10:02 by ursgraf