This chapter was the first one in the series of three chapters based on performance. It laid the ground work to improve application performance. We learned how to record the runtime using the time
module. We also saw how the timeit
module can be used to measure the performance of small pieces of code. We took a practical problem where an application ran fine when working with a small input, but, as the input grew larger, it slowed down considerably. With this example, we learned how to identify the bottlenecks using cProfile
and display the results using pstats
.
We saw how the line_profiler
module can help locate the time consuming statements inside a function. While most of the discussion was focused on the runtime performance, we briefly covered the memory_profiler
module. This module enabled line-by-line analysis of memory consumption for the given functions. Finally, we learned about the big O notation that represents the computational complexity of an algorithm.
Now that we have...