在Linux中分析部分程序

Met*_*est 6 linux profiler gprof

我有一个程序,其中花费了大量的时间来加载和保存数据.现在我想知道每个函数在总运行时间百分比方面花费了多少时间.但是,我想从分析器考虑的总时间中排除加载和保存函数所花费的时间.有没有办法使用gprof或任何其他流行的探查器?

seh*_*ehe 11

同样你可以使用

valgrind --tool=callgrind --collect-atstart=no --toggle-collect=<function> 
Run Code Online (Sandbox Code Playgroud)

其他选项:

--instr-atstart    # to avoid runtime overhead while not profiling
Run Code Online (Sandbox Code Playgroud)

获取指令级别统计信息:

--collect-jumps=yes
--dump-instr=yes
Run Code Online (Sandbox Code Playgroud)

另外,您可以"遥控器"它飞:callgrind_control或注释的源代码(IIRC也与分支预测统计)callgrind_annotate.

优秀的工具kcachegrind是一个奇妙的可视化/导航工具.我几乎不能推荐它:

在此输入图像描述


Dav*_*veR 5

我会考虑使用比现代更现代的东西gprof,比如OProfile.使用opreport您生成报告时,可以使用该--exclude-symbols选项排除您不感兴趣的功能.

有关详细信息,请参阅OProfile网页 ; 但是,有关快速入门指南,请参阅OProfile文档页面.