From 9da2f477b27f4d91a3b19f27095739a44e09f8b7 2014-10-04 18:47:48 From: MechCoder Date: 2014-10-04 18:47:48 Subject: [PATCH] Warnings are raised if the slowest timing is greater than 1e-6 It is often irritating when you do something like %timeit 3 and a warning pops up. This assumes that any timing less than a microsecond does not really matter --- diff --git a/IPython/core/magics/execution.py b/IPython/core/magics/execution.py index eaeb2fa..161951e 100644 --- a/IPython/core/magics/execution.py +++ b/IPython/core/magics/execution.py @@ -1027,7 +1027,10 @@ python-profiler package from non-free.""") worst = max(worst, worst_tuning) # Check best timing is greater than zero to avoid a # ZeroDivisionError. - if worst > 4 * best and best > 0: + # In cases where the slowest timing is lesser than a micosecond + # we assume that it does not really matter if the fastest + # timing is 4 times faster than the slowest timing or not. + if worst > 4 * best and best > 0 and worst > 1e-6: print("The slowest run took %0.2f times longer than the " "fastest. This could mean that an intermediate result " "is being cached " % (worst / best))