8

What is the difference between %time and %%time in a Jupyter Notebook Cell?

1 Answer 1

13

%time measures execution time of the next line.

%%time measures execution time of the whole cell.

For instance:

%time
a = 1
time.sleep(5)

CPU times: user 8 µs, sys: 0 ns, total: 8 µs Wall time: 16.9 µs

%%time
a = 1
time.sleep(5)

CPU times: user 1.13 ms, sys: 2.11 ms, total: 3.24 ms Wall time: 5 s

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.