1.一般linux系统自带perf,没有需要安装,没有需要安装
sudo apt install linux-tools-common linux-tools-generic
2.额外安装FlameGraph
git clone https://github.com/brendangregg/FlameGraph.git
3.运行
需要把运行库so拷贝到系统目录
sudo perf record -e cycles -F 99 -a -g -- ./**
(根据执行程序修改--后面内容)
sudo perf script -i perf.data &> perf-record.txt
sudo ../../../FlameGraph/stackcollapse-perf.pl ./perf-record.txt &> out.txt
sudo ../../../FlameGraph/flamegraph.pl ./out.txt > ./out.svg
out.svg即火焰图,用浏览器打开