0

As the title suggests, I'm looking to find the run time for my entire Jupyter notebook.

Perhaps something like %%time for the entire notebook. Have tried looking around for a solution, but I can't seem to find one that doesn't require me to define a function.

Any help would be appreciated, thank you guys!

JIST
  • 1,139
  • 2
  • 8
  • 30
orangecat94
  • 145
  • 3

1 Answers1

1

You can install and enable the Execute Time extension mentioned under section entitled '4. ExecuteTime: show when and how long cells ran', here. In the metadata, is the start_time and end_time for each cell, see here. You can use the start time for the first cell and the end_time for the last cell to give you the total time.

Alternatively, you can use an external call to run the notebook from another notebook and use %%time in that. For example to run the index.ipynb notebook, in a new notebook execute:

%%time
%run index.ipynb

You could use jupytext, papermill, or nbconvert to run the notebook instead of %run if you didn't want output displaying in your timing notebook. (I imagine the time to show that output might contribute and could matter in case of somethings you wish to time?) There is an example of using nbconvert and using the -t flag with the call to scripted version of the notebook to time it here.

Or you could use IPython to call to run the notebook and time this if you didn't want to use an actual separate Jupyter notebook since the %%time magic is inherited from IPython.

Wayne
  • 6,607
  • 8
  • 36
  • 93
  • Thanks Wayne for responding. After further trial and error, I believe I found out a slightly more straight forward method (at least for me). I imported the time library, and created a variable to start the timer right at the beginning of the notebook: ```t0 = time.time()``` At the end of the notebook, I found out the total time elapsed by: ```time.time() - t0``` Nonetheless, thank you for linking me to those sites above. While they were slightly complicated for me, I believe they will come in helpful in the near future/ – orangecat94 Mar 15 '20 at 11:25