Measuring CPU performance and execution time
When talking about performance you can measure a great number of things. When it comes to CPU performance, we can measure:
- The “wall time” (the absolute time on the clock).
- Relative time (when comparing multiple runs or multiple functions)
- Used CPU time. Due to multithreading, multiprocessing, or asynchronous processing, this can be vastly different from the wall time.
- When inspecting really low-level performance, measuring the number of CPU cycles and loop counts.
In addition to all these different measurement options, you should also consider the observer effect. Simply put, measuring takes time, and depending on how you are measuring the performance, the impact can be huge.
Within this section, we will be exploring several methods to inspect the CPU performance and execution time of your code. Tricks to improve your performance after measuring will come later in the chapter.
...