Code Profiling

22 Nov 2021 | computer programming

Optimizing

Perf

Perf is a set of Linux tools for command profiling.

Links:

Flame Graph

Flame graphs are visualizations of profiled software, allowing for the most frequence code paths to be identified quickly and accurately.

  1. Type git clone https://github.com/brendangregg/FlameGraph to acquire FlameGraph tools
  2. Type perf record -F max -a -g -- ./<executable> to capture executable
  3. Type perf script > out.perf to read perf.data (created by perf record) and save trace output
  4. Type ./FlameGraph/stackcollapse-perf.pl out.perf > out.folded to fold stack samples into single lines
  5. Type ./FlameGraph/flamegraph.pl out.folded > kernel.svg to render a SVG
  6. Type brave kernel.svg to view the SVG

Links: