S
Stephen C Phillips
Hi,
I have just started using the Python profiler and cannot get
the output I want. Once I have profiled a piece of code and saved the
data to a file, I can load it in using the pstats module. I have found
that 96% of my program's time is spent in three object methods (and their
callees) but want to know what the other 4% is.
I can do this:
p = pstats.Stats('profile.data')
p.print_callees('expensive_method1')
p.print_callees('expensive_method2')
p.print_callees('expensive_method3')
Which makes me think that the data must be held in a tree of some sort,
but what I want is to prune those branches from the tree and see the rest
of the data:
p.print_stats(without expensive_method[123])
I suppose I could roughly get this data by changing the three expensive
methods to immediately return some dummy data, but thought it ought to be
possible to interrogate the Stats object to get the answer.
The other 4% may also include calls to the same functions as in the 96% so
it is not just a matter of looking at the data for particular functions.
I know it seems silly to be chasing after 4% of the profile but it is
important in this case.
Thanks.
Stephen Phillips.
I have just started using the Python profiler and cannot get
the output I want. Once I have profiled a piece of code and saved the
data to a file, I can load it in using the pstats module. I have found
that 96% of my program's time is spent in three object methods (and their
callees) but want to know what the other 4% is.
I can do this:
p = pstats.Stats('profile.data')
p.print_callees('expensive_method1')
p.print_callees('expensive_method2')
p.print_callees('expensive_method3')
Which makes me think that the data must be held in a tree of some sort,
but what I want is to prune those branches from the tree and see the rest
of the data:
p.print_stats(without expensive_method[123])
I suppose I could roughly get this data by changing the three expensive
methods to immediately return some dummy data, but thought it ought to be
possible to interrogate the Stats object to get the answer.
The other 4% may also include calls to the same functions as in the 96% so
it is not just a matter of looking at the data for particular functions.
I know it seems silly to be chasing after 4% of the profile but it is
important in this case.
Thanks.
Stephen Phillips.