MCPcopy Index your code
hub / github.com/python/cpython / FakeTimer

Class FakeTimer

Lib/test/test_timeit.py:23–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21# of some functions that use the default as a default argument.
22
23class FakeTimer:
24 BASE_TIME = 42.0
25 def __init__(self, seconds_per_increment=1.0):
26 self.count = 0
27 self.setup_calls = 0
28 self.seconds_per_increment=seconds_per_increment
29 timeit._fake_timer = self
30
31 def __call__(self):
32 return self.BASE_TIME + self.count * self.seconds_per_increment
33
34 def inc(self):
35 self.count += 1
36
37 def setup(self):
38 self.setup_calls += 1
39
40 def wrap_timer(self, timer):
41 """Records 'timer' and returns self as callable timer."""
42 self.saved_timer = timer
43 return self
44
45class TestTimeit(unittest.TestCase):
46

Callers 8

timeitMethod · 0.85
repeatMethod · 0.85
run_mainMethod · 0.85
autorangeMethod · 0.85

Calls

no outgoing calls

Tested by 8

timeitMethod · 0.68
repeatMethod · 0.68
run_mainMethod · 0.68
autorangeMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…