@@ -99,7 +99,19 @@ The module defines the following public class:
9999 timeit.Timer('for i in range(10): oct(i)', 'gc.enable()').timeit()
100100
101101
102- The module also defines two convenience functions:
102+ The module also defines three convenience functions:
103+
104+
105+ .. function :: default_timer()
106+
107+ Define a default timer, in a platform specific manner. On Windows,
108+ :func: `time.clock ` has microsecond granularity but :func: `time.time `'s
109+ granularity is 1/60th of a second; on Unix, :func: `time.clock ` has 1/100th of
110+ a second granularity and :func: `time.time ` is much more precise. On either
111+ platform, :func: `default_timer ` measures wall clock time, not the CPU
112+ time. This means that other processes running on the same computer may
113+ interfere with the timing.
114+
103115
104116.. function :: repeat(stmt='pass', setup='pass', timer=<default timer>, repeat=3, number=1000000)
105117
@@ -161,13 +173,9 @@ similarly.
161173If :option: `-n ` is not given, a suitable number of loops is calculated by trying
162174successive powers of 10 until the total time is at least 0.2 seconds.
163175
164- The default timer function is platform dependent. On Windows,
165- :func: `time.clock ` has microsecond granularity but :func: `time.time `'s
166- granularity is 1/60th of a second; on Unix, :func: `time.clock ` has 1/100th of a
167- second granularity and :func: `time.time ` is much more precise. On either
168- platform, the default timer functions measure wall clock time, not the CPU time.
169- This means that other processes running on the same computer may interfere with
170- the timing. The best thing to do when accurate timing is necessary is to repeat
176+ :func: `default_timer ` measurations can be affected by other programs running on
177+ the same machine, so
178+ the best thing to do when accurate timing is necessary is to repeat
171179the timing a few times and use the best time. The :option: `-r ` option is good
172180for this; the default of 3 repetitions is probably enough in most cases. On
173181Unix, you can use :func: `time.clock ` to measure CPU time.
0 commit comments