[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Accumulating time from called functions in a profiler
- From: Martin Guy <martinwguy@...>
- Date: Tue, 3 May 2011 00:58:34 +0200
> If only the line wait(10) takes any time (10 time units), then should the child time for the *line* a(n-1) be 10 or 0?
It depends what you want to display on each line. If you want all the
numbers to add up to 100%, then it propagates 0 time to itself and the
10 delay is on the wait.
If you don't want the left hand column to add up to 100%, you need to
define more precisely what you mean by "time taken by each line".
The gprof remarks on this situation are here on p. 18-5:
The arcs from a routine to
itself are of interest, but do not participate in time propagation.
Thus the simple equation for time propaga-
tion does not work within strongly connected components. Time is not
propagated from one member of a
cycle to another, since, by definition, this involves propagating time
from a routine to itself. In addition,
children of one member of a cycle must be considered children of all
members of the cycle. Similarly, par-
ents of one member of the cycle must inherit all members of the cycle
as descendants. It is for these rea-
sons that we collapse connected components. Our solution collects all
members of a cycle together, sum-
ming the time and call counts for all members. All calls into the
cycle are made to share the total time of
the cycle, and all descendants of the cycle propagate time into the
cycle as a whole. Calls among the mem-
bers of the cycle do not propagate any time, though they are listed in
the call graph profile.