下载仓库 git clone https://github.com/brendangregg/FlameGraph.git

  1. perf -a -g -p [pid] (-a 采集所有cpu -g 采集堆栈)
  2. perf script -i perf.data &> perf.unfold (解析perf.data)
  3. ./stackcollapse-perf.pl perf.unfold > perf.folded (折叠符号)
  4. ./flamegraph.pl perf.folded > perf.svg (生成火焰图)