Saturday, December 6, 2014

IPython Tip of the Year: %timeit

Let's say you have written an amazing python function called amazing_function and you want to measure its speed.

Forget about manually importing time, and looping n times. Use:
  1. IPython
  2. IPython magic function %timeit:
$ ipython
In [1]: %timeit amazing_function('some', 'arguments')
100000 loops, best of 3: 13.4 ┬Ás per loop

No comments:

Post a Comment