Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jupyter Notebook time profiling

So I installed jupyter notebook through anaconda and I am working on python 3 kernel.

I am trying to do Time profiling using %time magic command as show here The problem is that it only prints the Wall Time not the CPU Time

using %time or %%time does not help

  • %time prints the wall time for the first line only
  • %%time prints the wall time for the whole cell

I am not sure if there any specif config to print the CPU time

EDIT

To clarify using %%time should print two metrics for the whole cell

  • Metric 1: CPU Times
  • Metric 2: wall time

my problem is that I only get wall time not CPU time.

You may check this link on what is the expected output for %%time

like image 764
Abdelrahman Shoman Avatar asked Mar 29 '17 09:03

Abdelrahman Shoman


People also ask

How do you display time on a Jupyter notebook?

Toggling display The menu item Cell -> Toggle timings -> All hides (shows) all the timing areas in the notebook, if the first cell is currently shown (hidden).

What is %% time in jupyter?

%%timeit in Jupyter Notebook The “%%timeit” command is used to measure the execution time of the entire cell code and can contain several code lines that may be written in the next line. The “%%timeit” is easiest to use because you need to enter “%%timeit” only at the start of the cell.

What is %% capture in Python?

IPython has a cell magic, %%capture , which captures the stdout/stderr of a cell. With this magic you can discard these streams or store them in a variable. from __future__ import print_function import sys. By default, %%capture discards these streams. This is a simple way to suppress unwanted output.


1 Answers

So it seems that my issue was in the environment itself.

Switching from Windows to Ubuntu actually helped me print the CPU times.

like image 183
Abdelrahman Shoman Avatar answered Sep 28 '22 06:09

Abdelrahman Shoman