Simple way to measure cell execution time in ipython notebook Simple way to measure cell execution time in ipython notebook python python

Simple way to measure cell execution time in ipython notebook


The only way I found to overcome this problem is by executing the last statement with print.

Do not forget that cell magic starts with %% and line magic starts with %.

%%timeclf = tree.DecisionTreeRegressor().fit(X_train, y_train)res = clf.predict(X_test)print(res)

Notice that any changes performed inside the cell are not taken into consideration in the next cells, something that is counter intuitive when there is a pipeline:an example


%time and %timeit now come part of ipython's built-in magic commands


An easier way is to use ExecuteTime plugin in jupyter_contrib_nbextensions package.

pip install jupyter_contrib_nbextensionsjupyter contrib nbextension install --userjupyter nbextension enable execute_time/ExecuteTime