User Tools

Site Tools


for_developers:timing_measurement

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
for_developers:timing_measurement [2016/09/13 14:03] – [How the timer works] gehrigfor_developers:timing_measurement [2016/10/24 07:55] – [Implementation] graf
Line 29: Line 29:
  
 ===== Implementation ===== ===== Implementation =====
-To integrate the measurement, following code has to be integrated after a task is created and before the task is added to the //Executor//Following example shows the integration of the measurement including creation and assignment to the executor of a control system:+To integrate the measurement, following code has to be integrated after a task is created and before the task is added to the //Executor//The following example shows the integration of the measurement including creation and assignment to the executor of a control system:
 <code cpp> <code cpp>
 using namespace eeros::logger; using namespace eeros::logger;
Line 35: Line 35:
  
  
-eeros::task::Periodic td("control system",dt, timedomain);+eeros::task::Periodic per("control system",dt, timedomain);
  
-td.monitors.push_back([&](eeros::PeriodicCounter &c, Logger<LogWriter> &log) {+per.monitors.push_back([&](PeriodicCounter &c, Logger<LogWriter> &log) {
  static int ticks = 0; // mseconds   static int ticks = 0; // mseconds
   
Line 44: 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)  << counter.period.max*1000  std::cout << "CS: period max: " << setw(7)  << counter.period.max*1000
Line 51: Line 51:
 }); });
  
-eeros::Executor::instance().add(td);+eeros::Executor::instance().add(per);
 </code> </code>