Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在一个文件中有一个 C 代码test.c。我必须使用grof对其进行分析。我使用以下命令来执行此操作。
test.c
gcc -p -o result test.c ./result gprof result
输出的一部分如下所示:
`平面轮廓:每个样本计为 0.01 秒。没有时间积累
% 累计 self 总 时间 秒 秒 呼叫 Ts/呼叫 Ts/呼叫名称`
问题是无论我使用什么复杂或简单的程序,每个样本计数都不会从 0.01 秒开始变化。为什么会这样,并且没有时间在各个列下累积和显示。
您对 gcc 使用了错误的命令行选项。 -p是针对不同的,较旧的分析器 - 对于gprof,您需要-pg.
-p
gprof
-pg
如果您仍然没有看到任何时间累积,这只是意味着您的程序没有消耗足够的 CPU 时间来注册 -gprof使用基于样本的分析,并且它运行的时间不够长,无法采集任何样本。