MCPcopy Index your code
hub / github.com/python/cpython / timeit

Method timeit

Lib/timeit.py:173–191  ·  view source on GitHub ↗

Time 'number' executions of the main statement. To be precise, this executes the setup statement once, and then returns the time it takes to execute the main statement a number of times, as float seconds if using the default timer. The argument is the number of tim

(self, number=default_number)

Source from the content-addressed store, hash-verified

171 traceback.print_exc(file=file, **kwargs)
172
173 def timeit(self, number=default_number):
174 """Time 'number' executions of the main statement.
175
176 To be precise, this executes the setup statement once, and
177 then returns the time it takes to execute the main statement
178 a number of times, as float seconds if using the default timer. The
179 argument is the number of times through the loop, defaulting
180 to one million. The main statement, the setup statement and
181 the timer function to be used are passed to the constructor.
182 """
183 it = itertools.repeat(None, number)
184 gcold = gc.isenabled()
185 gc.disable()
186 try:
187 timing = self.inner(it, self.timer)
188 finally:
189 if gcold:
190 gc.enable()
191 return timing
192
193 def repeat(self, repeat=default_repeat, number=default_number):
194 """Call timeit() a few times.

Callers 6

repeatMethod · 0.95
autorangeMethod · 0.95
timeitMethod · 0.95
test_print_excMethod · 0.95
benchFunction · 0.95
timeitFunction · 0.45

Calls 4

repeatMethod · 0.45
disableMethod · 0.45
innerMethod · 0.45
enableMethod · 0.45

Tested by 2

timeitMethod · 0.76
test_print_excMethod · 0.76