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

Class Timer

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

146
147
148class Timer(timeit.Timer):
149 """Timer class that explicitly uses self.inner
150
151 which is an undocumented implementation detail of CPython,
152 not shared by PyPy.
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.85

Calls

no outgoing calls

Tested by

no test coverage detected