timeit is a module that allows you to time pieces of code. It is part of the standard Python library. We will time the
sort() NumPy function with several array sizes. The classic quicksort and merge sort algorithms have an average running time of O(N log N), so we will try to fit our result to such a model.
We will require arrays to sort:
times = np.array() for size in sizes: integers = np.random.random_integers (1, 10 ** 6, size)
def measure(): timer = timeit.Timer('dosort()', 'from __main__ ...