admin管理员组

文章数量:1642339

perf

性能瓶颈的位置,性能瓶颈的类型(cachemisses还是io密集型)

perf record -e cpu-clock -g ./run

To make the adjusted perf_event_paranoid setting permanent preserve it in /etc/sysctl.conf (e.g. kernel.perf_event_paranoid = )

临时设置,需要sudo su切换到root用户后再进行如下操作,操作完成后返回原用户

sudo su

echo -1 > /proc/sys/kernel/perf_event_paranoid

sudo su - religiousj

sudo perf report -i perf.data,可以看出main函数所占百分比,以及funcA和funcB…分别所占百分比

sudo perf report -i perf.data

转化成火焰图,可视化分析:

系统级性能分析工具perf的介绍与使用 - ArnoldLu - 博客园
perf-系统级性能分析工具 _

Gprof

g++ -std=c++11 -O3 SLIC.cpp -pg -o SLIC
./SLIC
gprof SLIC gmon.out  > gprofresult.txt

SILC 为.exe文件 一般情况下用 test.exe

若图像形式输出

  1. python3
  2. gprof2dot和graphivz生成程序运行调用图

gprof2dot.py
https://pypi/project/gprof2dot/

graphivz

sudo apt install graphivz

方法:

python gprof2dot.py gprof_output.txt> call_graph.dot
dot -Tpng call_graph.dot -o call_graph.png
python gprof2dot.py gprofresult.txt> call_graph.dot

dot -Tpng call_graph.dot -o call_graph.png



使用gprof2dot和graphivz生成程序运行调用图

本文标签: 热点自带Linux