cpython: 45b208ae9eab (original) (raw)
Mercurial > cpython
changeset 91991:45b208ae9eab
#18588: merge with 3.4. [#18588]
Ezio Melotti ezio.melotti@gmail.com | |
---|---|
date | Mon, 04 Aug 2014 17:01:48 +0300 |
parents | a64806257119(current diff)c39457a07caa(diff) |
children | 944fc499ccd3 |
files | |
diffstat | 1 files changed, 10 insertions(+), 9 deletions(-)[+] [-] Doc/library/timeit.rst 19 |
line wrap: on
line diff
--- a/Doc/library/timeit.rst +++ b/Doc/library/timeit.rst @@ -28,22 +28,23 @@ can be used to compare three different e .. 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)
Note however that :mod:timeit
will automatically determine the number of
repetitions only when the command-line interface is used. In the