本文介绍了gprof将每个函数显示为100%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用经过修改的auditd程序包,并将gprof与之链接.

I'm using a modified auditd package, and linked gprof with it.

但是从gprof XX | gprof2dot | dot -Tpng output.png的输出来看,所有功能的使用率均为100%,因此我无法确定谁正在消耗大部分的CPU资源.

But from the output of gprof XX | gprof2dot | dot -Tpng output.png, all functions are 100% usage, so I cannot tell who's consuming most of the CPU resources.

(右键单击图像可查看全图)

(Right click on the image to have a full view)

有什么想法吗?那是正常的,最重要的是,我应该如何知道哪个功能消耗了最多的CPU?

Any ideas? Is that normal, and most importantly, how should I know which function consumes most CPU?

P.S:原始gprof输出 http://pastie.org/8546568

P.S: original gprof output http://pastie.org/8546568

推荐答案

直接配置文件顶部(在pastie.org链接中)是直接答案:

At the top of the flat profile (in the pastie.org link) is the immediate answer:

Flat profile:

Each sample counts as 0.01 seconds.
 no time accumulated

由于所有内容完全不花时间,因此所有内容都花费了与其他内容相同的时间.

Since everything took exactly no time at all, everything took the same amount of time as everything else.

更有趣的问题是,为什么所有事情都根本不花时间?

(To get a profile of a program that would be setuid, make a non-suid version of it, and profile that. Sometimes you need to tweak the internals a bit to make it behave well now that it's not setuid.)

经过更多的探索之后,我不知道为什么它失败了. Linux使用libc兼容性例程来伪造gprofprofil()系统调用.这需要基于SIGPROFITIMER_PROF间隔计时器,但通常应该可以使用.

After poking around some more, I don't know why it fails. Linux uses a libc compatibility routine to fake the profil() system call for gprof. This needs the SIGPROF-based ITIMER_PROF interval timer but should generally work.

一种替代方法是使用 OProfile ,它更具通用性(它可以分析系统调用),这些天可能得到更好的支持.

An alternative is to use OProfile, which is more general-purpose (it can profile system calls) and probably better-supported these days.

这篇关于gprof将每个函数显示为100%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 20:19