C++性能调优

12 篇文章 0 订阅

mkdir build && cd build
cmake -DCMAKE_CXX_COMPILER="%VCINSTALLDIR%/bin/cl.exe" -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="/mnt/include-what-you-use/build/bin/include-what-you-use" -G Ninja ..

export IWYU_BINARY=/mnt/include-what-you-use/build/bin/include-what-you-use
python3 /mnt/include-what-you-use/iwyu_tool.py -j 8 -p .> iwyu.out
python3 /mnt/include-what-you-use/fix_includes.py -b --comments --update_comments < iwyu.out


clang -pg -lstdc++ -o ./cmake/test ./cmake/cmake.cpp -lc_p
./cmake/test
gprof -b -qfunc1 fic_untilTool_test gmon.out>gmon.txt
gprof -b test gmon.out -Ffunc1 -efuncTest >gmon.txt
kprof -f ./test
gprof ./test | gprof2dot.py | xdot
-b 不显示描述
-A 显示函数源码
-pa 只打印a的flat profile,-Pa只屏蔽a
-qa 只打印a的call,-Qa只屏蔽a

sprof ./module.so Perf.profile -p >log.txt
time ./program
 
gcov ./summer-proj覆盖测试
gprof ./Perf | gprof2dot.py | dot -Tpng -o output.png
cd gprof2dot && cat ../bin/gmon.txt | python3 gprof2dot.py -n0 -e0 | dot -Tpdf -o output.pdf
编译开关-ftest-coverage -fprofile-arcs
改run.sh  换行类型

apt-get install ./libimagequant0_2.12.2-1.1_amd64.deb
apt-get install ./libimagequant-dev_2.12.2-1.1_amd64.deb

dpkg-deb -c quantum6.deb

泄露分析,编译链接-g
valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all ./bin/Perf
valgrind --tool=callgrind ../bin/Perf
python gprof2dot.py -f callgrind -n10 -s callgrind.out.31113 | dot -Tpng -o valgrind.png

pprof安装
export CPUPROFILE_FREQUENCY=1
go install github.com/google/pprof@latest
pprof --text ./Perf test_capture.prof > profile.txt
pprof --callgrind ./Perf test_capture.prof > callgrind.res
pprof  ./Perf test_capture.prof --web
pprof  ./Perf test_capture.prof --pdf > prof.pdf

查看-pg是否生效
-lc_p
nm libobjectmodule.so | grep mcount
ldd ./Perf | grep libc

apt-get install libpopt-dev
apt-get install libiberty-dev
apt-get install libfdt-dev

#Recommended profilers¶
VerySleepy (Windows only)
HotSpot (Linux only)
Xcode Instruments (macOS only)


创作不易,小小的支持一下吧!

  • 13
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

码力码力我爱你

创作不易,小小的支持一下吧!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值