火焰图生成

火焰图生成脚本
https://github.com/brendangregg/FlameGraph
git clone https://github.com/brendangregg/FlameGraph.git

#!/bin/bash

FLAMEGRAPH=/root/test/FlameGraph

echo "perf record ... gen perf.data"
perf record -F 99 -p $1 -g -- sleep 30

echo "gen out.perf"
perf script > out.perf


echo "gen out.folded"
${FLAMEGRAPH}/stackcollapse-perf.pl out.perf > out.folded


echo "genn svg"
${FLAMEGRAPH}/flamegraph.pl out.folded > perf.svg

合并之后

#!/bin/bash
FLAMEGRAPH=/root/test/FlameGraph
echo "perf record $1 30s"
perf record -F 99 -p $1 -g -- sleep 30
perf script | ${FLAMEGRAPH}/stackcollapse-perf.pl | ${FLAMEGRAPH}/flamegraph.pl > $1.svg

你可能感兴趣的:(C++)