MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / autorange

Method autorange

tools/python-3.11.9-amd64/Lib/timeit.py:212–231  ·  view source on GitHub ↗

Return the number of loops and time taken so that total time >= 0.2. Calls the timeit method with increasing numbers from the sequence 1, 2, 5, 10, 20, 50, ... until the time taken is at least 0.2 second. Returns (number, time_taken). If *callback* is given a

(self, callback=None)

Source from the content-addressed store, hash-verified

210 return r
211
212 def autorange(self, callback=None):
213 """Return the number of loops and time taken so that total time >= 0.2.
214
215 Calls the timeit method with increasing numbers from the sequence
216 1, 2, 5, 10, 20, 50, ... until the time taken is at least 0.2
217 second. Returns (number, time_taken).
218
219 If *callback* is given and is not None, it will be called after
220 each trial with two arguments: ``callback(number, time_taken)``.
221 """
222 i = 1
223 while True:
224 for j in 1, 2, 5:
225 number = i * j
226 time_taken = self.timeit(number)
227 if callback:
228 callback(number, time_taken)
229 if time_taken >= 0.2:
230 return (number, time_taken)
231 i *= 10
232
233
234def timeit(stmt="pass", setup="pass", timer=default_timer,

Callers 1

mainFunction · 0.95

Calls 2

timeitMethod · 0.95
callbackFunction · 0.70

Tested by

no test coverage detected