Reputation: 907
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?
Upvotes: 0
Views: 5442
Reputation: 4921
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.
Upvotes: 2