Skip to content

Instantly share code, notes, and snippets.

@Shengliang
Created March 3, 2017 23:49
Show Gist options
  • Save Shengliang/5885f975350e53cb42989b8e26868257 to your computer and use it in GitHub Desktop.
Save Shengliang/5885f975350e53cb42989b8e26868257 to your computer and use it in GitHub Desktop.
Flame graphs are a visualization of profiled software, allowing the most frequent code-paths
to be identified quickly and accurately.
http://www.brendangregg.com/Slides/LISA13_Flame_Graphs.pdf
http://www.brendangregg.com/flamegraphs.html
git clone https://github.com/brendangregg/FlameGraph.git
# example 1
sudo perf record -a -g -F 97 sleep 60
sudo perf script -f > out.stacks
~/src/FlameGraph/stackcollapse-perf.pl < out.stacks| grep -v cpu_idle > out.folded
~/src/FlameGraph/flamegraph.pl --title="Flame" out.folded > out.svg
view out.svg with web browser.
# example 2
$ sudo perf record -e cycles -ag -C 2 // control-c to stop recording
$ sudo perf report --stdio
$ sudo perf script > out.data
$ cat out.data | ~/src/FlameGraph/stackcollapse-perf.pl > out.filtered
$ cat out.filtered | ~/src/FlameGraph/flamegraph.pl > out.svg
$ less out.filtered
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment