The timeit package measures the execution time of code.
Solution for How to use timeit in Python : You can use timeit.timeit() to time the execution speed Use timeit.timeit(stmt, setup, number) to create a Timer instance that will execute the function represented by the string setup only once before executing the function represented by the string stmt a number of times. By default, number is 1000000. timeit.timeit() returns the code’s execution time in seconds.
Further reading:
You can read more about the timeit module here.