# \[Nav2\] New Profiling Tutorial!

**URL:** https://discourse.openrobotics.org/t/nav2-new-profiling-tutorial/26053
**Category:** ROS General
**Tags:** ros2
**Created:** [June 17, 2022, 11:37pm UTC](https://discourse.openrobotics.org/t/nav2-new-profiling-tutorial/26053 "2022-06-17T23:37:07Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![smac](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/smac/32/6763_2.png) [@smac](https://discourse.openrobotics.org/u/smac)
#### Post date: [June 17, 2022, 11:37pm UTC](https://discourse.openrobotics.org/t/nav2-new-profiling-tutorial/26053/1 "2022-06-17T23:37:07Z")

</div>

Hi all, your friendly neighborhood navigator here,

I wanted to bring to the community’s attention a new tutorial I wrote this afternoon for how to profile applications in ROS 2 with `valgrind`. This subject has come up a few times in the Nav2 working group while trying to analyze run-time performance and identify locations for improvements.

This tutorial focuses on the ROS-y aspects of profiling including how to profile from a launch file, `ros2 run` commandline, and with servers with plugins that you’d like to also profile. It ends briefly with using the profiler results in `kcachegrind` to see the Call Graph and analyze where in your server the time is being mostly spent.

[https://navigation.ros.org/tutorials/docs/get\_profile.html](https://navigation.ros.org/tutorials/docs/get_profile.html)

This is certainly not an exhaustive tutorial about all the things you can do with profilers and analysis you can derive from the results, but its a good starting point for new developers that haven’t used this technology before or are just looking to bridge their existing skills into ROS 2-based projects.

This compliments the [Backtrace Tutorial](https://navigation.ros.org/tutorials/docs/get_backtrace.html) I made 2 years ago (wow, I feel old now 😢 ) for our to get backtraces with ROS 2.

Happy profiling,

Steve

---

<div class="post-metadata">

### Author: ![Robin\_Tomar](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/robin_tomar/32/33928_2.png) [@Robin\_Tomar](https://discourse.openrobotics.org/u/Robin_Tomar)
#### Post date: [June 18, 2022, 2:59am UTC](https://discourse.openrobotics.org/t/nav2-new-profiling-tutorial/26053/2 "2022-06-18T02:59:40Z")

</div>

Hey steve, clean tutorial. Will try out and post results. just a quick question. Is it obvious that the function in which code stays the most is the one using most system resources or it could be otherwise .🧐

---

<div class="post-metadata">

### Author: ![smac](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/smac/32/6763_2.png) [@smac](https://discourse.openrobotics.org/u/smac)
#### Post date: [June 19, 2022, 10:32pm UTC](https://discourse.openrobotics.org/t/nav2-new-profiling-tutorial/26053/3 "2022-06-19T22:32:23Z")

</div>

Hi,

I’m not exactly sure what you’re trying to ask or I’m parsing the sentence incorrectly. Perhaps you could rephrase with more detail?

---

<div class="post-metadata">

### Author: ![ipa-hsd](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/ipa-hsd/32/2373_2.png) [@ipa-hsd](https://discourse.openrobotics.org/u/ipa-hsd)
#### Post date: [June 21, 2022, 9:44am UTC](https://discourse.openrobotics.org/t/nav2-new-profiling-tutorial/26053/4 "2022-06-21T09:44:15Z")

</div>

Thanks for the tutorial! Is there any way to integrate the results of such profilers in CI? Maybe to output a warning / error in case the recent commits degraded the performance of a function below a limit..?

---

<div class="post-metadata">

### Author: ![gavanderhoorn](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/gavanderhoorn/32/969_2.png) [@gavanderhoorn](https://discourse.openrobotics.org/u/gavanderhoorn)
#### Post date: [June 21, 2022, 11:43am UTC](https://discourse.openrobotics.org/t/nav2-new-profiling-tutorial/26053/5 "2022-06-21T11:43:57Z")

</div>

It’s not using @smac’s nice work, but for benchmarking you could take a look at how [tesseract does it](https://github.com/tesseract-robotics/tesseract/blob/2c593d12a0a470bd2672fdf6ff86843dd69b6e4a/.github/workflows/benchmarking.yml).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex022/uploads/ros/original/3X/b/6/b607ee3cc8e908b1b613bd74a683d749fea635a1.svg) [@system](https://discourse.openrobotics.org/u/system)
#### Post date: [July 21, 2022, 11:44am UTC](https://discourse.openrobotics.org/t/nav2-new-profiling-tutorial/26053/6 "2022-07-21T11:44:10Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
