Time the performance by timeit and cell magic
Goal¶
This post aims to introduce how to measure the running time of your code or function by using timeit
module and cell magic command %%time
and %%timeit
.
Reference *Time a Python Function
Libraries¶
import pandas as pd
import timeit
Measure a literal code¶
timeit.timeit('2**10')
Measure the execution time for a function¶
def execute_abc(x=10):
return 2 ** 10
timeit.timeit(execute_abc)
Measure the time by using Cell Magic in Jupyter Notebook¶
%%time
2**10
%timeit 2**10