I understand the concept of what timeit does but I am not sure how to implement it in my code.
timeit
How can I compare two functions, say insertion_sort
insertion_sort
I find the easiest way to use timeit is from the command line:
Given test.py:
def InsertionSort(): ... def TimSort(): ...
run timeit like this:
% python -mtimeit -s'import test' 'test.InsertionSort()' % python -mtimeit -s'import test' 'test.TimSort()'