When using IPython, it's often convenient to see how long your commands take to run by using the %time magic function. When you use this often enough, you start to wish that you could just get toggle a setting to get this metadata by default whenever you enter a query. Psql lets you do this with \timing. GHCi lets you do this with :set s+. Does IPython let you do this? And if not, why not?
Asked
Active
Viewed 52 times
1 Answers
0
The "ipythonic" way of timing code is using the %timeit or %%timeit magic function (respectively for online, and multi-line code).
These functions provide quite accurate results by running the code multiple times (the exact number is adaptive if not specified).
The global flag you are asking does not exist in ipython. Furthermore, just adding %%timeit
to all the cells will not work because global variables are not modified when calling %%timeit
. This "feature" is directly inherited from the timeit
module.
For more info see this ipython issue.

user2304916
- 7,882
- 5
- 39
- 53
-
I don't like it, but I'll accept this answer because the real one appears to be "no". – RussellStewart Sep 13 '14 at 18:05