diff options
author | Martin Panter <vadmium+py@gmail.com> | 2017-01-29 10:09:43 +0000 |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2017-01-29 10:09:43 +0000 |
commit | 6d1d733828b49eb03d45da81c6b8c6b849fbc5df (patch) | |
tree | b0b120d6c527fb8cf6e4a0f175556611673ad780 /Doc/library/timeit.rst | |
parent | 357e8cdc9b1c5a99be9ade2b1070c38d50ddadc6 (diff) | |
parent | 23282e54fdd766945930006ab606641a2db37a4c (diff) | |
download | cpython-6d1d733828b49eb03d45da81c6b8c6b849fbc5df.tar.gz |
Issues #29349: Merge Py 2 fix 3.5
Diffstat (limited to 'Doc/library/timeit.rst')
-rw-r--r-- | Doc/library/timeit.rst | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst index 57a4834c90..3b772765ac 100644 --- a/Doc/library/timeit.rst +++ b/Doc/library/timeit.rst @@ -100,8 +100,8 @@ The module defines three convenience functions and a public class: can be controlled by passing a namespace to *globals*. To measure the execution time of the first statement, use the :meth:`.timeit` - method. The :meth:`.repeat` method is a convenience to call :meth:`.timeit` - multiple times and return a list of results. + method. The :meth:`.repeat` and :meth:`.autorange` methods are convenience + methods to call :meth:`.timeit` multiple times. The execution time of *setup* is excluded from the overall timed execution run. @@ -134,6 +134,23 @@ The module defines three convenience functions and a public class: timeit.Timer('for i in range(10): oct(i)', 'gc.enable()').timeit() + .. method:: Timer.autorange(callback=None) + + Automatically determine how many times to call :meth:`.timeit`. + + This is a convenience function that calls :meth:`.timeit` repeatedly + so that the total time >= 0.2 second, returning the eventual + (number of loops, time taken for that number of loops). It calls + :meth:`.timeit` with *number* set to successive powers of ten (10, + 100, 1000, ...) up to a maximum of one billion, until the time taken + is at least 0.2 second, or the maximum is reached. + + If *callback* is given and is not ``None``, it will be called after + each trial with two arguments: ``callback(number, time_taken)``. + + .. versionadded:: 3.6 + + .. method:: Timer.repeat(repeat=3, number=1000000) Call :meth:`.timeit` a few times. |