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