gprof: Assumptions

1 
1 6.2 Estimating 'children' Times
1 ===============================
1 
1 Some of the figures in the call graph are estimates--for example, the
1 'children' time values and all the time figures in caller and subroutine
1 lines.
1 
1    There is no direct information about these measurements in the
1 profile data itself.  Instead, 'gprof' estimates them by making an
1 assumption about your program that might or might not be true.
1 
1    The assumption made is that the average time spent in each call to
1 any function 'foo' is not correlated with who called 'foo'.  If 'foo'
1 used 5 seconds in all, and 2/5 of the calls to 'foo' came from 'a', then
1 'foo' contributes 2 seconds to 'a''s 'children' time, by assumption.
1 
1    This assumption is usually true enough, but for some programs it is
1 far from true.  Suppose that 'foo' returns very quickly when its
1 argument is zero; suppose that 'a' always passes zero as an argument,
1 while other callers of 'foo' pass other arguments.  In this program, all
1 the time spent in 'foo' is in the calls from callers other than 'a'.
1 But 'gprof' has no way of knowing this; it will blindly and incorrectly
1 charge 2 seconds of time in 'foo' to the children of 'a'.
1 
1    We hope some day to put more complete data into 'gmon.out', so that
1 this assumption is no longer needed, if we can figure out how.  For the
1 novice, the estimated figures are usually more useful than misleading.
1