0

I am using Python 2.7 with Pycharm.

I have a very large project, and somewhere in the stack there is a function that takes an abnormal amount of time to complete.

I tried to time my functions manually (adding start = time.time() and end = time.time() and displaying end-start) but there are a lot of functions, a lot of iterations and recursive calls. Logging times didn't help. I also tried to use the debugger, but debugging by clicking through the code skews the actual computation time.

Can anyone suggest a better way of determining which function in my project takes a long time?

ANSWER

PyCharm has an integrated profiler, so I used that.

RandomGuyqwert
  • 425
  • 6
  • 18
  • 1
    Possible duplicate: [How can you profile a python script?](http://stackoverflow.com/questions/582336/how-can-you-profile-a-python-script) – Kyle Pittman Jan 25 '16 at 17:11
  • 2
    What you are trying to do is called profiling, you need a profiler for Python – zch Jan 25 '16 at 17:12
  • Thanks! I'll try cProfiler and let you know how it went! – RandomGuyqwert Jan 25 '16 at 17:28
  • If it's a particular function invocation that's being abnormal, just run the program and kill it part-way through. The traceback should include the problematic function with reasonably high likelihood. Repeat this a few times to make sure you've got the right thing. – Veedrac Jan 26 '16 at 01:28

0 Answers0