Compare the execution time between 2 functions

If you want to compare the execution time between 2 functions, the easiest method to measure the time is timeit.timeit. You can also specify the number of times you want to rerun your function to get a better estimation of the time. Below is the code

Something you might not know: it is faster to use list range than to use list comprehension.

Scroll to Top