Skip to content

Instantly share code, notes, and snippets.

@suhr
Last active August 29, 2015 14:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save suhr/95e9dafd01342b06a985 to your computer and use it in GitHub Desktop.
Save suhr/95e9dafd01342b06a985 to your computer and use it in GitHub Desktop.

Why so slow? Creating a flamegraph of your program with perf

Flamegraphs can help to optimize the program a lot. So let's create one!

  • Install perf with use flag unwind enabled
  • Download flamegraph.pl and stackcolllapse-perf.pl
  • Run perf record -F 99 --call-graph dwarf -- ‹your program›
  • Do all the things that make your program slow
  • Close your program
  • Run perf script | stackcollapse-perf.pl > out.folded
  • And finally, flamegraph is created by flamegraph.pl out.folded > flamegraph.svg command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment