自从升级到IPython版本3(我有3.1.0)以来,每次使用该%timeit命令时,它都会打印出"最慢的运行时间比最快的时间长[数倍].这可能意味着在打印之前正在缓存中间结果"时间结果.即使是非常简单的操作也会发生这种 例如:
In [4]: x = 5
In [5]: %timeit x
The slowest run took 53.99 times longer than the fastest. This could mean that an intermediate result is being cached
100000000 loops, best of 3: 19.8 ns per loop
Run Code Online (Sandbox Code Playgroud)
和:
In [17]: %timeit 22 + 1
The slowest run took 106.15 times longer than the fastest. This could mean that an intermediate result is being cached
100000000 loops, best of 3: 12.2 ns per loop
Run Code Online (Sandbox Code Playgroud)
只有少数情况我可以让它不会发生,例如:
In [15]: %timeit 5
100000000 loops, best of 3: 8.37 ns per loop
Run Code Online (Sandbox Code Playgroud)
我知道在某种程度上可能会有一些缓存(例如,正如其他答案所解释的那样),但是这个消息令人分心并且没有用处.有没有办法把它关掉?
| 归档时间: |
|
| 查看次数: |
1313 次 |
| 最近记录: |