MCPcopy Index your code
hub / github.com/RustPython/RustPython / timeit

Method timeit

Lib/timeit.py:163–181  ·  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

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

Callers 5

repeatMethod · 0.95
autorangeMethod · 0.95
timeitMethod · 0.95
test_print_excMethod · 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