A flamegraph is a convenient tool for understanding how CPU time is being used.
-
To start, run the docker container in privileged mode:
docker/run.sh -p
-
Your code needs to be built with debug info and may also need frame pointers. For that, use:
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_FLAGS="-fno-omit-frame-pointer"
-
Run the following script to generate the profiling data:
source /ws/install/setup.bash ros2 run beluga_benchmark profile_amcl_with_bagfile
perf
will generate aperf.data
file in the folder it was run. -
To generate a flamegraph from the recorded data, run:
source /ws/install/setup.bash ros2 run beluga_benchmark flamegraph # This may take a long time
To visualize the flamegraph and be able to zoom it in or out, open the generated
svg
file in a web-browser.