[Python-checkins] cpython (2.7): Issue #13478: document timeit.default_timer()

sandro.tosi python-checkins at python.org
Tue Apr 24 18:13:59 CEST 2012


http://hg.python.org/cpython/rev/86b927859155
changeset:   76524:86b927859155
branch:      2.7
parent:      76521:4dda3000c932
user:        Sandro Tosi <sandro.tosi at gmail.com>
date:        Tue Apr 24 18:11:29 2012 +0200
summary:
  Issue #13478: document timeit.default_timer()

files:
  Doc/library/timeit.rst |  22 ++++++++++++++--------
  1 files changed, 14 insertions(+), 8 deletions(-)


diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst
--- a/Doc/library/timeit.rst
+++ b/Doc/library/timeit.rst
@@ -101,9 +101,19 @@
 
          timeit.Timer('for i in xrange(10): oct(i)', 'gc.enable()').timeit()
 
-Starting with version 2.6, the module also defines two convenience functions:
+The module also defines three convenience functions:
 
 
+.. function:: default_timer()
+
+   Define a default timer, in a platform specific manner. On Windows,
+   :func:`time.clock` has microsecond granularity but :func:`time.time`'s
+   granularity is 1/60th of a second; on Unix, :func:`time.clock` has 1/100th of
+   a second granularity and :func:`time.time` is much more precise.  On either
+   platform, :func:`default_timer` measures wall clock time, not the CPU
+   time.  This means that other processes running on the same computer may
+   interfere with the timing.
+
 .. function:: repeat(stmt[, setup[, timer[, repeat=3 [, number=1000000]]]])
 
    Create a :class:`Timer` instance with the given statement, setup code and timer
@@ -168,13 +178,9 @@
 If :option:`-n` is not given, a suitable number of loops is calculated by trying
 successive powers of 10 until the total time is at least 0.2 seconds.
 
-The default timer function is platform dependent.  On Windows,
-:func:`time.clock` has microsecond granularity but :func:`time.time`'s
-granularity is 1/60th of a second; on Unix, :func:`time.clock` has 1/100th of a
-second granularity and :func:`time.time` is much more precise.  On either
-platform, the default timer functions measure wall clock time, not the CPU time.
-This means that other processes running on the same computer may interfere with
-the timing.  The best thing to do when accurate timing is necessary is to repeat
+:func:`default_timer` measurations can be affected by other programs running on
+the same machine, so
+the best thing to do when accurate timing is necessary is to repeat
 the timing a few times and use the best time.  The :option:`-r` option is good
 for this; the default of 3 repetitions is probably enough in most cases.  On
 Unix, you can use :func:`time.clock` to measure CPU time.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list