0

I have a Python function in which I want to find most slowing-down places. Just not I'm using cProfile, but I have an additional functionality.

I don't want to split my function into a dozen of sub-functions: it looks a bit bulky and annoying.

Isn't there instead a way to profile a function line-by-line? Or add something like timer_start(timer_id) and timer_stop(timer_id) before and after each block of code I want to profile execution time?

Felix
  • 3,351
  • 6
  • 40
  • 68

1 Answers1

0

If you are not using IPython already, you should give it a look. It has magic functions like %lprun which make line-by-line profiling easy. Take a look at Timing and Profiling in IPython

David Greydanus
  • 2,551
  • 1
  • 23
  • 42
fixxxer
  • 15,568
  • 15
  • 58
  • 76