Difference between revisions of "Profiling ROS Nodes"

From RoboJackets Wiki
Jump to navigation Jump to search
(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...")
 
 
Line 8: Line 8:
  
  
Usage with rosrun:
+
Profiling with rosrun:
   valgrind --tool=callgrind --callgrind-out-file=/path/to/file rosrun pkg node
+
   rosrun --prefix="valgrind --tool=callgrind --callgrind-out-file=outfile" pkg node
   kcachegrind /path/to/file
+
   kcachegrind outfile
 
 
  
 
Usage with roslaunch:
 
Usage with roslaunch:
   <node pkg="pkg" type="type" name="name" launch-prefix="valgrind --tool=callgrind --callgrind-out-file='/path/to/file'"/>
+
   foo.launch:
 +
    <launch>
 +
      <node pkg="a" type="a" name="a" launch-prefix="valgrind --tool=callgrind --callgrind-out-file=outfile"/>
 +
    </launch>
 +
  roslaunch foo.launch
 +
  kcachegrind ~/.ros/outfile
  
 
[[Category:Software]]
 
[[Category:Software]]
 
[[Category:RoboRacing]]
 
[[Category:RoboRacing]]

Latest revision as of 14:55, 19 September 2019

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


Profiling with rosrun:

 rosrun --prefix="valgrind --tool=callgrind --callgrind-out-file=outfile" pkg node
 kcachegrind outfile

Usage with roslaunch:

 foo.launch:
   <launch>
     <node pkg="a" type="a" name="a" launch-prefix="valgrind --tool=callgrind --callgrind-out-file=outfile"/>
   </launch>
 roslaunch foo.launch
 kcachegrind ~/.ros/outfile