summaryrefslogtreecommitdiff
path: root/Doc/library/timeit.rst
diff options
context:
space:
mode:
authorMariatta Wijaya <mariatta.wijaya@gmail.com>2017-02-06 20:16:58 -0800
committerMariatta Wijaya <mariatta.wijaya@gmail.com>2017-02-06 20:16:58 -0800
commitda79bcf8ac7ae72218ab023e1ed54390bc1a3a27 (patch)
tree74845e2dbd9521d9748b9c32f1922f4123083bf3 /Doc/library/timeit.rst
parente3c7e835bdfc97750eb9b7fc0ad2493108c2d438 (diff)
parent1fe806ac56f8b83694d24ab604eb695d00bc8497 (diff)
downloadcpython-da79bcf8ac7ae72218ab023e1ed54390bc1a3a27.tar.gz
Issue #29371: merge with 3.5
Diffstat (limited to 'Doc/library/timeit.rst')
-rw-r--r--Doc/library/timeit.rst21
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.