This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
cs:profiling:start [2017/01/02 11:58] James Irwin [Notes on Optimizing Code] |
cs:profiling:start [2017/01/13 15:00] (current) Brandon Kallaher [C++] |
||
---|---|---|---|
Line 9: | Line 9: | ||
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.<pid>''. | 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.<pid>''. | ||
- | Next, load up this output file with kcachgrind: | + | Next, load up this output file with kcachegrind: |
kcachegrind callgrind.out.<pid> | kcachegrind callgrind.out.<pid> | ||
===== Python ===== | ===== Python ===== | ||
- | Run your program iwth profiling turned on: | + | Run your program with profiling turned on: |
python -m cProfile -o <profile file name> <script>.py | python -m cProfile -o <profile file name> <script>.py | ||
Line 29: | Line 29: | ||
Just because you can optimize doesn't mean it's worth the effort. Remember, the control system is just a drop in the bucket compared to the vision processing system. Look at the overall CPU usage of a node relative to all others to determine if optimization is warranted. | Just because you can optimize doesn't mean it's worth the effort. Remember, the control system is just a drop in the bucket compared to the vision processing system. Look at the overall CPU usage of a node relative to all others to determine if optimization is warranted. | ||
+ | |||
+ | ====== Profiling Caveats ====== | ||
+ | [[http://yosefk.com/blog/how-profilers-lie-the-cases-of-gprof-and-kcachegrind.html|Here]] is a great article on how profilers can lie to us. |