Identifying the bottlenecks
In the previous section, we saw how a different choice of input parameters degrades the application runtime. Now, we need some way to accurately measure the execution time and find out the performance bottlenecks or the time consuming blocks of the code.
Measuring the execution time
Let's start by monitoring the time taken by the application. To do this, we will use Python's built-in time
module. The time.perf_counter
function is a performance counter that returns a clock with the highest available resolution. This function can be used to determine the time interval or the system-wide time difference between the two consecutive calls to the function.
Tip
The time.perf_counter
function is available in Python versions 3.3 ...
Get Learning Python Application Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.