I used cProfile to profile my code and it worked perfectly. I also use gprof2dot.py to visualize the results (makes this a bit clearer).
However, cProfile (and most of the other Python profilers I've seen so far) seems to only profile at the function call level. This is confusing when certain functions are called from different places - I have no idea if call number 1 or call number 2 takes up most of the time. This gets even worse when the function in question has six depth levels called up from seven other places.
How do I get line profiling?
Instead of this:
function
I would like to see something like this:
function #12 (called from somefile.py:102) 0.5s function #12 (called from main.py:12) 1.5s
cProfile shows how much time the parent spends all the time, but again this connection is lost when you have several layers and interconnected calls.
Ideally, I would like to have a graphical interface that will analyze the data and then show me my source file with the total time specified for each line. Something like that:
main.py: a = 1
Then I can click on the second call to "func (c)" to see what takes time in this call, separately from the call to "func (a)".
Does this make sense? Is there a profiling library that collects this type of information? Is there some awesome tool I missed?
python profiling
rocketmonkeys Oct 13 '10 at 20:12 2010-10-13 20:12
source share