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

Class Timer

IPython/core/magics/execution.py:162–188  ·  view source on GitHub ↗

Timer class that explicitly uses self.inner which is an undocumented implementation detail of CPython, not shared by PyPy.

Source from the content-addressed store, hash-verified

160
161
162class Timer(timeit.Timer):
163 """Timer class that explicitly uses self.inner
164
165 which is an undocumented implementation detail of CPython,
166 not shared by PyPy.
167 """
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.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…