3

I am working on a code with relatively few iterations (like, less than 100) and the total time is still several minutes. This means complexity is of no help and I don't really know what operations take most of the cpu time. This is annoying as i want to repeat that operation thousands of times. I want to reduce that time.

I know how to use time.clock() and return the difference but i am looking for a way to know the time spent on each line to know where and if an improvement can be made. Is there a mode already built for that on python? (3.4, windows)

Ashargin
  • 498
  • 4
  • 11
  • 1
    check out [profiler](https://docs.python.org/2/library/profile.html) – Alex Fung Feb 20 '17 at 13:46
  • @jonrsharpe that's my new favorite post xD – Piotr Kamoda Feb 20 '17 at 13:50
  • 1
    Why always a lot of answers are redirected to the wrong address It should be redirected to [how can i profile python code line by line](http://stackoverflow.com/questions/3927628/how-can-i-profile-python-code-line-by-line)!!!!!This is absolutely misleading! – McGrady Feb 20 '17 at 13:53
  • Links to related questions removed by the close mechanism: [How can you profile a script?](http://stackoverflow.com/questions/582336/how-can-you-profile-a-script), [How can I profile python code line-by-line?](http://stackoverflow.com/questions/3927628/how-can-i-profile-python-code-line-by-line), [Check running time per line in python](http://stackoverflow.com/questions/17314366/check-running-time-per-line-in-python). – poke Feb 20 '17 at 13:54

0 Answers0