puzzling gprof output in number of calls

169 Views Asked by At

I use -O0 -g -pg during compile. The number of calls is confusing. I have a function foo() which calls bar(). But the call count for foo() is far less than bar(), the number that shows how many times bar() is called from foo() is much less than the total number of times foo() is called. Both foo() and bar() are tiny function. But according to here: http://www.cs.utah.edu/dept/old/texinfo/as/gprof.html#SEC12, the number of calls figures should be accurate.

I google and find out a report online has the similar issue and I demonstrate it here.

http://badgertronics.com/writings/gprofsample.html

If we look at [3], DefaultUrlToFile, the total number of calls is 107244, but below that, you can see 214488/268156 Ns_UrlSpecificGet [12]

This means 214488 times of calls to Ns_UrlSpecificGet comes from DefaultUrlToFile, how can this possible when the total number of calls is 107244?

In section [12], it has

0.19 2.06 214488/268156 DefaultUrlToFile [3]

[12] 13.4 0.23 2.58 268156 Ns_UrlSpecificGet [12]

How can we explain this? The article associated with the report above is here http://badgertronics.com/writings/gprof.html but it does not explain this situation. The example in the article is perfect but in the other parts of the report, I see many examples of mismatches like above.

0

There are 0 best solutions below