Possible Duplicate:
How can you profile a Python script?
I have using cProfile to find out what method spent me most of the time on my python code, here is an output after sorting for "percall":
I found that the method len() spent me most of the time:
53515/533   330 930 0   940 00{len}
However, I know that len() call would call the python object __len__() method, how do I know what python class/object spent me the most?
I was using python 2.6.5 and run my script using:
python -m cProfile myscript.py
In fact, my code will use python-numpy, scipy and work on doing numerical optimization using Newton's method. I believe the calculation of the gradient of the objective function spent me most of the time and would like to find out the reason why it spent so much.
 
     
    