使用火焰图对程序进行性能分析
目录
使用
官网链接:https://www.brendangregg.com/flamegraphs.html
分为5种场景:
- CPU
- Memory
- Off-CPU
- Hot/Cold
- Differential
CPU
git clone https://github.com/brendangregg/FlameGraph
cd FlameGraph
# -a是分析全部进程,可使用"-p 进程pid"来指定唯一进程
perf record -F 99 -a -g -- sleep 60
perf script | ./stackcollapse-perf.pl > out.perf-folded
./flamegraph.pl out.perf-folded > perf.svg
chrome perf.svg