This is a list of commands useful for profiling binaries in Linux and
analysing the result.
Simple perf#
1
| perf record -g -- ./binary
|
Perf with better call graph#
-F 99
lowers the frequency because dwarf
produces large results.
--call-graph=lbr
is another option.
1
| perf record --call-graph=dwarf -F 99 -- ./binary
|
Simple report#
Generating flamegraph#
Install flamegraph-git from AUR.
The generated image is interactive, so open it with a browser.
1
| perf script | stackcollapse-perf | flamegraph > flamegraph.svg
|
CMake#
Run the following command to build a suitable profiling binary in a CMake project.
1
| cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo
|