summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2014-08-04 14:01:48 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2014-08-04 14:01:48 (GMT)
commitb398d3e4415291cd3fc779c1b49b10c5e39cde50 (patch)
tree5431319cdba04eb31ed77d107fea40a2cf3032ec /Doc
parentf5b182160d39225f7d03a7fa647ac00821d04716 (diff)
parent591176e544dfeec4586e239d5d07c6420a650f2c (diff)
downloadcpython-b398d3e4415291cd3fc779c1b49b10c5e39cde50.zip
cpython-b398d3e4415291cd3fc779c1b49b10c5e39cde50.tar.gz
cpython-b398d3e4415291cd3fc779c1b49b10c5e39cde50.tar.bz2
#18588: merge with 3.4.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/timeit.rst19
1 files changed, 10 insertions, 9 deletions
diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst
index 824a8a3..19b5e4e 100644
--- a/Doc/library/timeit.rst
+++ b/Doc/library/timeit.rst
@@ -28,22 +28,23 @@ can be used to compare three different expressions:
.. code-block:: sh
- $ python -m timeit '"-".join(str(n) for n in range(100))'
- 10000 loops, best of 3: 40.3 usec per loop
- $ python -m timeit '"-".join([str(n) for n in range(100)])'
- 10000 loops, best of 3: 33.4 usec per loop
- $ python -m timeit '"-".join(map(str, range(100)))'
- 10000 loops, best of 3: 25.2 usec per loop
+ $ python3 -m timeit '"-".join(str(n) for n in range(100))'
+ 10000 loops, best of 3: 30.2 usec per loop
+ $ python3 -m timeit '"-".join([str(n) for n in range(100)])'
+ 10000 loops, best of 3: 27.5 usec per loop
+ $ python3 -m timeit '"-".join(map(str, range(100)))'
+ 10000 loops, best of 3: 23.2 usec per loop
This can be achieved from the :ref:`python-interface` with::
>>> import timeit
>>> timeit.timeit('"-".join(str(n) for n in range(100))', number=10000)
- 0.8187260627746582
+ 0.3018611848820001
>>> timeit.timeit('"-".join([str(n) for n in range(100)])', number=10000)
- 0.7288308143615723
+ 0.2727368790656328
>>> timeit.timeit('"-".join(map(str, range(100)))', number=10000)
- 0.5858950614929199
+ 0.23702679807320237
+
Note however that :mod:`timeit` will automatically determine the number of
repetitions only when the command-line interface is used. In the