Profiling ROS Nodes

From RoboJackets Wiki
Revision as of 14:08, 19 September 2019 by Ebretl3 (talk | contribs) (Created page with "Here is a guide for one effective method for profiling the performance of ROS nodes. It uses valgrind to count the number of calls to every function and the amount of time spe...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Here is a guide for one effective method for profiling the performance of ROS nodes. It uses valgrind to count the number of calls to every function and the amount of time spent in each call, and uses KCacheGrind to visualize and explore this data in a nice GUI.

Note: any usage of profilers and code analysis tools like valgrind, gdb, etc require building with debug symbols. catkin_make in default configuration (DEBUG) has debug symbols but also has many optimizations turned off.


Installation:

 sudo apt install valgrind kcachegrind


Usage with rosrun:

 valgrind --tool=callgrind --callgrind-out-file=/path/to/file rosrun pkg node
 kcachegrind /path/to/file


Usage with roslaunch:

 <node pkg="pkg" type="type" name="name" launch-prefix="valgrind --tool=callgrind --callgrind-out-file='/path/to/file'"/>