[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Accumulating time from called functions in a profiler
- From: Geoff Leyland <geoff_leyland@...>
- Date: Tue, 3 May 2011 12:32:17 +1200
On 3/05/2011, at 10:58 AM, Martin Guy wrote:
>> 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.
That's what I fear :-( In which case I'd like to solicit opinions on what other people think should be displayed for 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.
Yes, the self and child times for the function a() are the sum of the self and child times for each line, which is nice. However, the sum of the self and child time for the line a(n-1) is not the time spent on that line and in its callees (what you'd measure by wrapping the line in two calls to os.clock())
If, on the other hand, you do attribute the 10 to a(n-1) then the self and child times of the function are not the sums of the self and child times of its lines (the correct times can be calculated, of course), but the time for the line a(n-1) is the time that you'd measure with os.clock().
So, as far as I can tell, there are at least two defendable options. Can anyone knock one or other defense over or express a preference?
> The gprof remarks on this situation are here on p. 18-5:
Yes, I read that. Am I right in thinking that they're not talking about line-by-line profiling, and that in the presence of recursive functions they pretty much say that it gets complicated? If I understand correctly, for their solution the child time for the line a(n-1) would be 0, and if they had a chain of a() calling b() calling a(), then the result they'd get for the line b(n-1) in function a() would be uninformative.
Cheers,
Geoff