Timing our code
Sometimes, we need to know how much time does our code takes to execute.
We can do that so in many ways, one of them being to use the perf_counter()
function.
The perf_counter()
function gives us the current timestamp. It alone is not as useful but if we call the function at the start and the end of program and subtract both the timestamps we get the execution time of the code.
Using perf_counter()
We will create a class Timer
to use this perf_counter()
as this will help us to use this more and more.