How can I configure my IPython notebook so it always shows the execution time as part of the output?

jupyter-notebook

Solution

This ipython extension does what you want: https://github.com/cpcloud/ipython-autotime

load it by putting this at the top of your notebook:

`%install_ext https://raw.github.com/cpcloud/ipython-autotime/master/autotime.py %load_ext autotime`

Once loaded, every subsequent cell execution will include the time it took to execute as part of its output.

Problem

Sometimes I execute a method that takes long to compute ``` In [1]: long_running_invocation() Out[1]: ``` Often I am interested in knowing how much time it took, so I have to write this: ``` In[2]: import time start = time.time() long_running_invocation() end = time.time() print end - start Out[2]: 1024 ``` Is there a way to configure my IPython notebook so that it automatically prints the execution time of every call I am making like in the following example? ``` In [1]: long_running_invocation() Out[1] (1.59s): ```

Original source