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

Method timeit

IPython/core/magics/execution.py:170–188  ·  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 a float measured in seconds. The argument is the number of times through the

(self, number=timeit.default_number)

Source from the content-addressed store, hash-verified

168
169 # Timer.timeit copied from CPython 3.4.2
170 def timeit(self, number=timeit.default_number):
171 """Time 'number' executions of the main statement.
172
173 To be precise, this executes the setup statement once, and
174 then returns the time it takes to execute the main statement
175 a number of times, as a float measured in seconds. The
176 argument is the number of times through the loop, defaulting
177 to one million. The main statement, the setup statement and
178 the timer function to be used are passed to the constructor.
179 """
180 it = itertools.repeat(None, number)
181 gcold = gc.isenabled()
182 gc.disable()
183 try:
184 timing = self.inner(it, self.timer)
185 finally:
186 if gcold:
187 gc.enable()
188 return timing
189
190
191@magics_class

Callers 1

timeitMethod · 0.95

Calls 1

innerMethod · 0.80

Tested by

no test coverage detected