File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ jupytext:
4
4
extension : .md
5
5
format_name : myst
6
6
format_version : 0.13
7
- jupytext_version : 1.16.1
7
+ jupytext_version : 1.16.6
8
8
kernelspec :
9
9
display_name : Python 3 (ipykernel)
10
10
language : python
@@ -348,7 +348,15 @@ The compiled versions for the previous array size are still available in memory
348
348
too, and the following call is dispatched to the correct compiled code.
349
349
350
350
``` {code-cell} ipython3
351
- %time f(x).block_until_ready()
351
+ %timeit f(x).block_until_ready()
352
+ ```
353
+
354
+ ``` {note}
355
+ Note that we use the [`%timeit` magic](https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-timeit)
356
+ here to get more reliable timing statistics.
357
+
358
+ It runs the code multiple times to calculate both mean and standard deviation,
359
+ which takes longer but provides more accurate measurements than a single run.
352
360
```
353
361
354
362
### Compiling the outer function
@@ -368,14 +376,13 @@ f_jit(x)
368
376
And now let's time it.
369
377
370
378
``` {code-cell} ipython3
371
- %time f_jit(x).block_until_ready()
379
+ %timeit f_jit(x).block_until_ready()
372
380
```
373
381
374
382
Note the speed gain.
375
383
376
384
This is because the array operations are fused and no intermediate arrays are created.
377
385
378
-
379
386
Incidentally, a more common syntax when targetting a function for the JIT
380
387
compiler is
381
388
You can’t perform that action at this time.
0 commit comments