MCPcopy Create free account
hub / github.com/ipython/ipython / timeit

Method timeit

IPython/core/magics/execution.py:155–173  ·  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

153 """
154 # Timer.timeit copied from CPython 3.4.2
155 def timeit(self, number=timeit.default_number):
156 """Time 'number' executions of the main statement.
157
158 To be precise, this executes the setup statement once, and
159 then returns the time it takes to execute the main statement
160 a number of times, as a float measured in seconds. The
161 argument is the number of times through the loop, defaulting
162 to one million. The main statement, the setup statement and
163 the timer function to be used are passed to the constructor.
164 """
165 it = itertools.repeat(None, number)
166 gcold = gc.isenabled()
167 gc.disable()
168 try:
169 timing = self.inner(it, self.timer)
170 finally:
171 if gcold:
172 gc.enable()
173 return timing
174
175
176@magics_class

Callers 1

timeitMethod · 0.95

Calls 2

disableMethod · 0.45
enableMethod · 0.45

Tested by

no test coverage detected