0

In my code, the execution time of my for loop is increasing by roughly 1 second after roughly 1000 iteration. So, I am suspecting, there is something wrong within my for loop. I have break point after 1000 iteration, but i need to know which line is taking more time. use of time.time() while line-by-line debugging is certainly not a good idea. I could have used timeit to get the exact execution time for a block of code but it also not a good idea for my case, because i need to get the execution time of each line within a for loop, but not the whole loop. In this case what should i do? I am using pycharm for debugging. is there any option in this editor?

1

1 Answer 1

2

If you're using professional version of PyCharm, you can use builtin profiler.

Otherwise, refer to this answer. Alternatively, you can have a look at line_profiler.

Sign up to request clarification or add additional context in comments.

2 Comments

Just run the program with pycharm's default cProfiler, but i can not sees anything that say excution time for a line.
On statistics page you can see what caused most load: how much time it was called and for how long. Otherwise, have a look at line_profiler or memory_profiler.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.