2026/11/2 10:42:31

C++性能调优

C++性能调优 mkdir build cd buildcmake -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-usepython3 /mnt/include-what-you-use/iwyu_tool.py -j 8 -p . iwyu.outpython3 /mnt/include-what-you-use/fix_includes.py -b --comments --update_comments iwyu.outclang -pg -lstdc -o ./cmake/test ./cmake/cmake.cpp -lc_p./cmake/testgprof -b -qfunc1 fic_untilTool_test gmon.outgmon.txtgprof -b test gmon.out -Ffunc1 -efuncTest gmon.txtkprof -f ./testgprof ./test | gprof2dot.py | xdot-b 不显示描述-A 显示函数源码-pa 只打印a的flat profile,-Pa只屏蔽a-qa 只打印a的call,-Qa只屏蔽asprof ./module.so Perf.profile -p log.txttime ./programgcov ./summer-proj覆盖测试gprof ./Perf | gprof2dot.py | dot -Tpng -o output.pngcd 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.debapt-get install ./libimagequant-dev_2.12.2-1.1_amd64.debdpkg-deb -c quantum6.deb泄露分析,编译链接-gvalgrind --toolmemcheck --leak-checkfull --show-leak-kindsall ./bin/Perfvalgrind --toolcallgrind ../bin/Perfpython gprof2dot.py -f callgrind -n10 -s callgrind.out.31113 | dot -Tpng -o valgrind.pngpprof安装export CPUPROFILE_FREQUENCY1go install github.com/google/pproflatestpprof --text ./Perf test_capture.prof profile.txtpprof --callgrind ./Perf test_capture.prof callgrind.respprof ./Perf test_capture.prof --webpprof ./Perf test_capture.prof --pdf prof.pdf查看-pg是否生效-lc_pnm libobjectmodule.so | grep mcountldd ./Perf | grep libcapt-get install libpopt-devapt-get install libiberty-devapt-get install libfdt-dev#Recommended profilers¶VerySleepy (Windows only)HotSpot (Linux only)Xcode Instruments (macOS only)创作不易小小的支持一下吧