2.1 Introduction random walk example
foni opened this issue · 2 comments
foni commented
Hi,
I cannot wrap my head around the big difference between the execution times when I use timeit() from tools.py versus the ipython magic function %timeit. can someone help me?
Regards,
fonis.
%timeit "random_walk_fastest(n=10000)"
7.52 ns ± 0.258 ns per loop (mean ± std. dev. of 7 runs, 100000000 loops each)
timeit("random_walk_fastest(n=10000)", globals())
1000 loops, best of 3: 99 usec per loop
ashwinvis commented
WhatYou don't need the quotes while calling the magic. Try:
%timeit random_walk_fastest(n=10000)
foni commented
Thanks a lot. Without the quotes, the measurements are very close.
So with quotes, %timeit was just evaluating the string literal expression "random_walk_fastest(n=10000)" instead of calling random_walk_fastest() function.