0
$\begingroup$

Rosanswers logo

I would like to know, is there such a tool in ROS that I can use it to profile the total duration of time taken (or time-complexity) by each node that I'm running.

Thanks in advance.


Originally posted by alfa_80 on ROS Answers with karma: 1053 on 2012-02-23

Post score: 7

$\endgroup$

3 Answers 3

0
$\begingroup$

Rosanswers logo

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

$\endgroup$
0
$\begingroup$

Rosanswers logo

Are you looking for the runtime of an executable? In this case start the node using the unix-tool "time" (see "man time"). If you are using launch files, have a look at the launch-prefix attribute of the "node" tag:

<node pkg="somepkg" type="somename" name="somename" launch-prefix="time">

Originally posted by Felix Endres with karma: 6468 on 2012-02-24

This answer was NOT ACCEPTED on the original site

Post score: 4


Original comments

Comment by alfa_80 on 2012-02-24:
With the above line, I won't be able to know how much time is used for each of nodes I've, right? I've tried it, and it gives only one "elapsed"(time elapsed i guess).

Comment by Felix Endres on 2012-02-26:
I am sorry, but I do not understand your question. What exactly do you want to measure? "time" gives you the duration a program is running from startup until shutdown.

Comment by alfa_80 on 2012-02-27:
Yes, it is. Thanks anyway. Only that, I couldn't be able to differentiate which one belongs to which process/node?

Comment by Felix Endres on 2012-02-27:
The -f option of time lets you print out arbitrary output. Have a look at time's man-page.

$\endgroup$
0
$\begingroup$

Rosanswers logo

While Valgrind is nice I tend to use sysprof more often. You can install it with:

sudo apt-get install sysprof

Originally posted by Thomas D with karma: 4347 on 2012-02-24

This answer was NOT ACCEPTED on the original site

Post score: 4


Original comments

Comment by Asomerville on 2013-04-02:
This avoids valgrind's vm & single thread distortions, and so in many cases is a much better option.

Comment by Roberto on 2013-08-23:
I am trying to use sysprof with my ros code, but unfortunately I don't get it to run on ubuntu 12.04 x64. Do you know if it is possible?

Comment by Thomas D on 2013-08-23:
I used sysprof yesterday when running ROS nodes and it worked when I used sudo.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.