def test_pct_timer(self): r = Registry( config=SidecarConfig({"sidecar.output-location": "memory"})) t = r.pct_timer("test") self.assertTrue(t._writer.is_empty()) t.record(42) self.assertEqual("T:test:42", t._writer.last_line())
def test_pct_timer_stopwatch(self): clock = ManualClock() r = Registry(clock=clock, config=SidecarConfig( {"sidecar.output-location": "memory"})) t = r.pct_timer("test") with t.stopwatch(): clock.set_monotonic_time(42) self.assertEqual("T:test:42", t._writer.last_line())