[Documentation] [TitleIndex] [WordIndex

Note: This tutorial assumes that you have completed the previous tutorials: Stopwatch.
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Benchmarking

Description: Tools to assist benchmarking programs.

Tutorial Level: INTERMEDIATE

CpuWatch

/!\ Requires : librt

This is a variation of the stopwatch for systems with librt. The time measured by the cpu watch is not system time, rather the time spent by the process actually exeucting on the cpu. This is very useful for benchmarking programs. Usage is exactly the same as for the stopwatch class.

TimeData

It is useful when used with the TimeData class - this class helps store timings from a CpuWatch and then analysing them with some statistical methods.

   1 CpuWatch cpuwatch;
   2 TimeData timings;
   3 ecl::Duration duration;
   4 for ( unsigned int i = 0; i < 100; ++i ) {
   5     cpuwatch.restart();
   6     // do some work here
   7     duration = cpuwatch.split();
   8     timings.push_back(duration);
   9 }
  10 std::cout << "Average : " << timings.average() << std::endl;
  11 std::cout << "Variance: " << timings.variance() << std::endl;


2020-01-25 12:37