summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-03-13 19:32:21 (GMT)
committerGeorg Brandl <georg@python.org>2007-03-13 19:32:21 (GMT)
commitd9bef35e3c0c4c1dfa5760fd76c720afa1956170 (patch)
tree9310de1abf31a7ad9bc914379765af806a0978a4 /Doc
parent4168c0466f873b60dd82ea83782e39a41a3aa45f (diff)
downloadcpython-d9bef35e3c0c4c1dfa5760fd76c720afa1956170.zip
cpython-d9bef35e3c0c4c1dfa5760fd76c720afa1956170.tar.gz
cpython-d9bef35e3c0c4c1dfa5760fd76c720afa1956170.tar.bz2
Patch #1533909: the timeit module now accepts callables in addition to
strings for the code to time and the setup code. Also added two convenience functions for instantiating a Timer and calling its methods.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libtimeit.tex25
1 files changed, 25 insertions, 0 deletions
diff --git a/Doc/lib/libtimeit.tex b/Doc/lib/libtimeit.tex
index 1c4e05b..f4f3cc7 100644
--- a/Doc/lib/libtimeit.tex
+++ b/Doc/lib/libtimeit.tex
@@ -31,6 +31,13 @@ To measure the execution time of the first statement, use the
\method{timeit()} method. The \method{repeat()} method is a
convenience to call \method{timeit()} multiple times and return a list
of results.
+
+\versionchanged[The \var{stmt} and \var{setup} parameters can now also
+ take objects that are callable without arguments. This
+ will embed calls to them in a timer function that will
+ then be executed by \method{timeit()}. Note that the timing
+ overhead is a little larger in this case because of the
+ extra function calls]{2.6}
\end{classdesc}
\begin{methoddesc}{print_exc}{\optional{file=\constant{None}}}
@@ -97,6 +104,24 @@ measured. If so, GC can be re-enabled as the first statement in the
\end{methoddesc}
+Starting with version 2.6, the module also defines two convenience functions:
+
+\begin{funcdesc}{repeat}{stmt\optional{, setup\optional{, timer\optional{,
+ repeat\code{=3} \optional{, number\code{=1000000}}}}}}
+Create a \class{Timer} instance with the given statement, setup code and timer
+function and run its \method{repeat} method with the given repeat count and
+\var{number} executions.
+\versionadded{2.6}
+\end{funcdesc}
+
+\begin{funcdesc}{timeit}{stmt\optional{, setup\optional{, timer\optional{,
+ number\code{=1000000}}}}}
+Create a \class{Timer} instance with the given statement, setup code and timer
+function and run its \method{timeit} method with \var{number} executions.
+\versionadded{2.6}
+\end{funcdesc}
+
+
\subsection{Command Line Interface}
When called as a program from the command line, the following form is used: