##// END OF EJS Templates
Update timeit documentation: replace best time with average time
komo-fr -
Show More
@@ -109,12 +109,12 b' class BasicMagics(Magics):'
109 Created `%%t` as an alias for `%%timeit`.
109 Created `%%t` as an alias for `%%timeit`.
110
110
111 In [2]: %t -n1 pass
111 In [2]: %t -n1 pass
112 1 loops, best of 3: 954 ns per loop
112 107 ns ± 43.6 ns per loop (mean ± std. dev. of 7 runs, 1 loop each)
113
113
114 In [3]: %%t -n1
114 In [3]: %%t -n1
115 ...: pass
115 ...: pass
116 ...:
116 ...:
117 1 loops, best of 3: 954 ns per loop
117 107 ns ± 58.3 ns per loop (mean ± std. dev. of 7 runs, 1 loop each)
118
118
119 In [4]: %alias_magic --cell whereami pwd
119 In [4]: %alias_magic --cell whereami pwd
120 UsageError: Cell magic function `%%pwd` not found.
120 UsageError: Cell magic function `%%pwd` not found.
@@ -1050,7 +1050,7 b' class ExecutionMagics(Magics):'
1050 provided, <N> is determined so as to get sufficient accuracy.
1050 provided, <N> is determined so as to get sufficient accuracy.
1051
1051
1052 -r<R>: number of repeats <R>, each consisting of <N> loops, and take the
1052 -r<R>: number of repeats <R>, each consisting of <N> loops, and take the
1053 best result.
1053 average result.
1054 Default: 7
1054 Default: 7
1055
1055
1056 -t: use time.time to measure the time, which is the default on Unix.
1056 -t: use time.time to measure the time, which is the default on Unix.
@@ -218,10 +218,10 b' Magics support assignment:'
218 .. code-block:: ipython
218 .. code-block:: ipython
219
219
220 In [1]: results = %timeit -r1 -n1 -o list(range(1000))
220 In [1]: results = %timeit -r1 -n1 -o list(range(1000))
221 1 loops, best of 1: 21.1 µs per loop
221 62.1 µs ± 0 ns per loop (mean ± std. dev. of 1 run, 1 loop each)
222
222
223 In [2]: results
223 In [2]: results
224 Out[2]: <TimeitResult : 1 loops, best of 1: 21.1 µs per loop>
224 <TimeitResult : 62.1 µs ± 0 ns per loop (mean ± std. dev. of 1 run, 1 loop each)>
225
225
226 Magics with double percent signs (``%%``) can spread over multiple lines, but they do not support assignments:
226 Magics with double percent signs (``%%``) can spread over multiple lines, but they do not support assignments:
227
227
@@ -117,7 +117,7 b' The following uses the builtin :magic:`timeit` in cell mode::'
117 ...: min(x)
117 ...: min(x)
118 ...: max(x)
118 ...: max(x)
119 ...:
119 ...:
120 1000 loops, best of 3: 438 us per loop
120 518 µs ± 4.39 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
121
121
122 In this case, ``x = range(10000)`` is called as the line argument, and the
122 In this case, ``x = range(10000)`` is called as the line argument, and the
123 block with ``min(x)`` and ``max(x)`` is called as the cell body. The
123 block with ``min(x)`` and ``max(x)`` is called as the cell body. The
@@ -133,12 +133,12 b' The following examples show how to call the built-in :magic:`timeit` magic, both'
133 in line and cell mode::
133 in line and cell mode::
134
134
135 In [1]: %timeit range(1000)
135 In [1]: %timeit range(1000)
136 100000 loops, best of 3: 7.76 us per loop
136 179 ns ± 2.66 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
137
137
138 In [2]: %%timeit x = range(10000)
138 In [2]: %%timeit x = range(10000)
139 ...: max(x)
139 ...: max(x)
140 ...:
140 ...:
141 1000 loops, best of 3: 223 us per loop
141 264 µs ± 1 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
142
142
143 The built-in magics include:
143 The built-in magics include:
144
144
@@ -172,10 +172,10 b' Main features of the interactive shell'
172 .. sourcecode:: ipython
172 .. sourcecode:: ipython
173
173
174 In [1]: %timeit 1+1
174 In [1]: %timeit 1+1
175 10000000 loops, best of 3: 25.5 ns per loop
175 7.88 ns ± 0.0494 ns per loop (mean ± std. dev. of 7 runs, 100000000 loops each)
176
176
177 In [2]: %timeit [math.sin(x) for x in range(5000)]
177 In [2]: %timeit [math.sin(x) for x in range(5000)]
178 1000 loops, best of 3: 719 µs per loop
178 608 µs ± 5.57 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
179
179
180 ..
180 ..
181
181
General Comments 0
You need to be logged in to leave comments. Login now