我分析了一些在 Linux 上运行的非常简单的 C++ 程序。main() 的包含成本远非 100%,大约为 3.83%。我是否正确使用了 callgrind?我在下面粘贴了callgrind_annotatewith的输出--inclusive=yes。
该程序称为堆,它执行简单的堆排序。我使用的命令是
valgrind --tool=callgrind ./heap
Run Code Online (Sandbox Code Playgroud)
然后,我输入
callgrind_annotate --inclusive=yes callgrind.out.25434
Run Code Online (Sandbox Code Playgroud)
输出:
`--------------------------------------------------------------------------------
Profile data file 'callgrind.out.25434' (creator: callgrind-3.6.0)
`--------------------------------------------------------------------------------
I1 cache:
D1 cache:
LL cache:
Timerange: Basic block 0 - 361578
Trigger: Program termination
Profiled target: ./heap (PID 25434, part 1)
Events recorded: Ir
Events shown: Ir
Event sort order: Ir
Thresholds: 99
Include dirs:
User annotated:
Auto-annotation: off
`--------------------------------------------------------------------------------
Ir
`--------------------------------------------------------------------------------
2,552,558 PROGRAM TOTALS
`--------------------------------------------------------------------------------
Ir file:function
`-------------------------------------------------------------------------------- …Run Code Online (Sandbox Code Playgroud)