linux - 在 Linux 中分析部分程序

标签 linux profiler gprof

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

最佳答案

同样你可以使用

valgrind --tool=callgrind --collect-atstart=no --toggle-collect=<function> 

要查看的其他选项:

--instr-atstart    # to avoid runtime overhead while not profiling

获取指令级统计数据:

--collect-jumps=yes
--dump-instr=yes

或者,您可以即时“远程控制”它:callgrind_control 或注释您的源代码(IIRC 也有分支预测统计信息): callgrind_annotate

优秀的工具 kcachegrind 是一个了不起的可视化/导航工具。我怎么推荐都不为过:

enter image description here

关于linux - 在 Linux 中分析部分程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6617501/

相关文章:

mongodb - 如何在不同的嵌套级别上搜索 MongoDB-Documents?

javascript - 从 Internet Explorer 外部调用 Jscript 分析器?

c - 无法使用 gprof 分析 libcrypto 方法

mpi - 如何在 MPI 代码上从 gprof 获得有意义的结果?

linux - Qt 如何获取分区id?

linux - 删除 : filter out text containing ONLY specific characters

linux - 重新链接匿名(未链接但打开)文件

c++ - 如何衡量 pimpl 候选人?

c - gprof 是否考虑了阻塞时间?

linux - 无法连接到 digitalocean 上的 docker-machine 容器