If you're looking to perform more in-depth timing analysis of your nodes, you can run the node in Valgrind. This will allow you to see the time usage of each function in your program, step by step. A node can be run in Valgrind by using a launch-prefix.
Originally posted by DimitriProsser with karma: 11163 on 2012-02-24
This answer was ACCEPTED on the original site
Post score: 7
Original comments
Comment by alfa_80 on 2012-02-24:
If I run Valgrind by using a launch-prefix, where do I check the output?
Comment by DimitriProsser on 2012-02-24:
Use launch-prefix="valgrind --log-file=/home/your_user/valgrind.log
to log to that file. I would then suggest you open that file in a valgrind gui of some kind. I use Kcachegrind on Ubuntu.
Comment by alfa_80 on 2012-02-24:
I've got a permission problem to open the file via Kcachegrind. When I check the generated logfile, it not a read-only file. Any hint for this..
Comment by DimitriProsser on 2012-02-24:
Are you running ROS as a different user?
Comment by alfa_80 on 2012-02-24:
No, the same user.
Comment by DimitriProsser on 2012-02-24:
You could just do chmod 775 valgrind.log
to change the permissions.
Comment by alfa_80 on 2012-02-24:
It's not the case of having permission problem, I think, could be something else. Any other possibilities I can open that via Kcachegrind?
Comment by Asomerville on 2013-04-02:
Valgrind is not a good solution unfortunately because it's effectively a virtual machine that runs a single thread. It greatly affects the way a process runs distorting the costs. @Thomas_D's suggestion of sysprof avoids this issue though.
Comment by kun on 2017-07-11:
In ~/catkin_ws/devel/lib/yourpackage
, run the command in bash: valgrind --tool=callgrind ./yournode
, you will get the right log file in the same path, the file name looks like 'callgrind.out.8521', use kcachegrind callgrind.out.8521
to open the log file.
Comment by Kei Okada on 2018-08-02:
HI, thanks for information, I have added new wiki for using valgrind on ROS. Any contributions are welcome. http://wiki.ros.org/roslaunch/Tutorials/Profiling%20roslaunch%20nodes