Skip to content

Instantly share code, notes, and snippets.

@misha354
Created January 22, 2019 17:02
Show Gist options
  • Save misha354/1565f597c8f6d0ef376b3561fb937979 to your computer and use it in GitHub Desktop.
Save misha354/1565f597c8f6d0ef376b3561fb937979 to your computer and use it in GitHub Desktop.
perf record -e sched:sched_stat_sleep -e sched:sched_switch -e sched:sched_process_exit -a -g --call-graph=dwarf -o perf.data.raw --pid $(pgrep named | head -n 1) -- sleep 10
perf inject -v -s -i perf.data.raw -o perf.data
perf script -F comm,pid,tid,cpu,time,period,event,ip,sym,dso,trace | awk '
NF > 4 { exec = $1; period_ms = int($5 / 1000000) }
NF > 1 && NF <= 4 && period_ms > 0 { print $2 }
NF < 2 && period_ms > 0 { printf "%s\n%d\n\n", exec, period_ms }' | \
./stackcollapse.pl | \
./flamegraph.pl --countname=ms --title="Off-CPU Time Flame Graph" --colors=io > offcpu.svg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment