MCPcopy Index your code
hub / github.com/RustPython/RustPython / FakeTimer

Class FakeTimer

Lib/test/test_timeit.py:22–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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