perf可记录高达700多种events事件。
sudo perf list #可以查看可以perf的事件
sudo perf record -F 999 -e cpu-clock,faults -a -g -p 28544 -- sleep 60
#制定进程7424采集cpu-clock和pagefault两个指标,全系统采集,控制频率999 要求caller/callee, 采集60秒,注意 -- sleep 之间有一个空格
# -g : enables call-graph recording and display
# -a : system-wide collection from all CPUs
# -p : profile events on existing process id
# -F : 每秒采集多少事件
# 上面的命令生成 perf.daa
#预处理
sudo perf script > out.perf
#clone仓库
git clone git@github.com:brendangregg/FlameGraph.git
#打平stack
./stackcollapse-perf.pl out.perf > out.folded
#生成火焰图
./flamegraph.pl out.folded > out.svg
参考:
http://www.brendangregg.com/perf.html
http://www.brendangregg.com/flamegraphs.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)