There are magics for timing execution of code with a similar syntax to the standard ones in Python.
%time 2**128
You are able to execute few statements in single line.
%time a = [10,20,30,40,50]; a= a.sum(); a*10;
Time measurement in cell mode
%%time
a = [10,20,30,40,50];
a= a.sum();
a*10;
Function %time
provides very basic timing functionality.
Use the timeit magic for more control over the measurement.
Time execution of a Python statement or expression
Usage, in line mode:
%timeit [-n<N> -r<R> -q] statement
or in cell mode:
%%timeit
code
code...```
Options:
-n<N>: execute the given statement <N> times in a loop. If this value is not given, a fitting value is chosen.
-r<R>: repeat the loop iteration <R> times and take the best result. Default: 3
-q: Quiet, do not print result.
%timeit -n10 -r3 sin(100)*cos(123)
%timeit -r3 sin(100)*cos(123)
%timeit -r3 -n1 sleep(1000)
%%timeit -r3 -n10
a = 15;
b = 111;
a * b;