增加脚本用于生产火焰图

1_collect_data.sh    : 采集指定 CPU 的运行数据
	2_conversion_data.sh :将采集的数据转化成火焰图
This commit is contained in:
luwenpeng
2021-07-14 10:44:54 +00:00
parent 0153e061f6
commit 7a8342a048
2 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
#!/bin/bash
if [ ! -n "$1" ]; then
echo "Please input CPU ID !"
exit 0
fi
# 执行后在当前目录下会生成采样数据 perf.data
rm -rf perf.data
perf record -e cpu-clock --call-graph dwarf -C $1 -- sleep 10

View File

@@ -0,0 +1,26 @@
#!/bin/bash
if [ ! -f "perf.data" ]; then
echo "Please Collect data !"
exit 0
fi
if [ ! -d FlameGraph ]; then
echo "git clone https://github.com/brendangregg/FlameGraph.git"
git clone https://github.com/brendangregg/FlameGraph.git
fi
rm -rf perf.unfold
rm -rf perf.folded
rm -rf perf.svg
# 用 perf script 工具对 perf.data 进行解析
perf script -i perf.data &> perf.unfold
# 将 perf.unfold 中的符号进行折叠
./FlameGraph/stackcollapse-perf.pl perf.unfold &> perf.folded
# 生成 svg 图
./FlameGraph/flamegraph.pl perf.folded > perf.svg
# 使用浏览器查看 perf.svg, 在浏览器中使用 Ctrl + F 进行关键字搜索