diff options
author | Raymond Hettinger <python@rcn.com> | 2004-01-04 21:19:18 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-01-04 21:19:18 (GMT) |
commit | c14149e6ef0a2878035396d02e67caed02396990 (patch) | |
tree | 10162baefcf870cc3345b4161273226c8ef91a11 /Doc/lib/libtimeit.tex | |
parent | 2b2c97356f178579be673fad2eb8032f98d91b44 (diff) | |
download | cpython-c14149e6ef0a2878035396d02e67caed02396990.zip cpython-c14149e6ef0a2878035396d02e67caed02396990.tar.gz cpython-c14149e6ef0a2878035396d02e67caed02396990.tar.bz2 |
Show how to re-enable GC during timings.
Diffstat (limited to 'Doc/lib/libtimeit.tex')
-rw-r--r-- | Doc/lib/libtimeit.tex | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Doc/lib/libtimeit.tex b/Doc/lib/libtimeit.tex index 98c1c83..1c4e05b 100644 --- a/Doc/lib/libtimeit.tex +++ b/Doc/lib/libtimeit.tex @@ -82,6 +82,18 @@ times, measured in seconds as a float. The argument is the number of times through the loop, defaulting to one million. The main statement, the setup statement and the timer function to be used are passed to the constructor. + +\begin{notice} +By default, \method{timeit()} temporarily turns off garbage collection +during the timing. The advantage of this approach is that it makes +independent timings more comparable. This disadvantage is that GC +may be an important component of the performance of the function being +measured. If so, GC can be re-enabled as the first statement in the +\var{setup} string. For example: +\begin{verbatim} + timeit.Timer('for i in xrange(10): oct(i)', 'gc.enable()').timeit() +\end{verbatim} +\end{notice} \end{methoddesc} |