====== Profiling ====== Code profiling is the process of identifying where in a program a CPU is spending most of its time. If you need to speed up your program, profiling your code will help identify where you should optimize! The following instructions are based on [[http://projects.csail.mit.edu/pr2/wiki/index.php?title=Profiling_Code_in_ROS|this website]]. ===== C++ ===== Run valgrind on your program: valgrind --tool=callgrind This will start up your node. Let it run for a while, then use ''rosnode kill'' to kill your node, and valgrind will dump its output to a file called ''callgrind.out.''. Next, load up this output file with kcachegrind: kcachegrind callgrind.out. ===== Python ===== Run your program with profiling turned on: python -m cProfile -o