summaryrefslogtreecommitdiff
path: root/Doc/library/timeit.rst
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2017-02-01 22:37:49 +0300
committerBerker Peksag <berker.peksag@gmail.com>2017-02-01 22:37:49 +0300
commita706118dafc16edfed490c53db02c08aefe7b097 (patch)
tree6416a9ea3398ea769857b79a8036f9ffe098c95e /Doc/library/timeit.rst
parent1966772d17f49c740be143d9d4622be13e850f15 (diff)
parentba5a055a00d91a449a23ae14dd468e9b769a6b74 (diff)
downloadcpython-a706118dafc16edfed490c53db02c08aefe7b097.tar.gz
Issue #29407: Merge from 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.