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
Next revision
Previous revision
tools:monitor:start [2018/11/21 08:49] – [How to use the Timer] graftools: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 is included in every periodic object. It registers the system time each time the executor executes this particular task (//tick()//). When the task is done, the system time is registered again (//tock()//). The timer keeps track of the previous measurement and calculates the run time in between consecutive runs as well as period and jitter. +The timer is implemented in ''eeros::PeriodicFunction'' and is included in every periodic object. It registers the system time each time the executor executes this particular task (//tick()//). When the task is done, the system time is registered again (//tock()//). The timer keeps track of the previous measurement and calculates the run time in between consecutive runs as well as period and jitter. 
   * 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 90: 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.
  
 +===== Measuring a Single Block =====
 +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>
 +#include <eeros/core/PeriodicCounter.hpp>   // add include file
 +
 +eeros::PeriodicCounter pc;                  // add periodic counter object to your block
  
 +virtual void run() {
 +  pc.tick();                                // start ...
 +  ... // algorithm
 +  pc.tock();                                // ... and stop the timer
 +</code> 
 +You can then periodically print the mean and maximum run time.
tools/monitor/start.1542786563.txt.gz · Last modified: 2018/11/21 08:49 by graf