perf + flamegraph

Oct 20, 2023

perf Only works on linux, but:

Shows that to get a flamegraph of where a binary is spending its time, you can use steps like this:

# git clone # or download it from github # cd FlameGraph # perf record -F 99 -a -g -- sleep 60 # perf script | ./ > out.perf-folded # ./ out.perf-folded > perf.svg # firefox perf.svg # or chrome, etc.

I saw this in a thread about Zig performance, somebody used perf+flamegraph to analyze a program and notice that all its time was spent reading a file (was using an unbuffered read - 28 million syscalls intead of a few k) instead of performing useful work.

↑ up