#!/bin/bash
PID=`ps -ef | grep /bin/metafs_server(替换成你需要的程序) | grep -v grep | awk '{print $2}'`
if [ ${#PID} -eq 0 ]
then
echo "process not found"
exit -1
fi
echo "1:"
perf record -F 99 -g -p $PID -- sleep 60
echo "2:"
perf script -i perf.data &> perf.unfold
echo "3:"
FlameGraph/stackcollapse-perf.pl perf.unfold &> perf.folded
echo "4:"
FlameGraph/flamegraph.pl perf.folded > perf.svg
rm -rf perf.data* perf.folded perf.unfold
标签:脚本,grep,perf,folded,PID,echo,火焰,unfold
From: https://www.cnblogs.com/lygin/p/16730771.html