Merge 46b410c60d into 4900e5e866
This commit is contained in:
commit
32cb80e688
|
|
@ -0,0 +1,13 @@
|
|||
from toolkit.timer import Timer
|
||||
|
||||
|
||||
def test_print_ignores_cancelled_timer_without_samples():
|
||||
timer = Timer()
|
||||
printed_timings = []
|
||||
timer.add_after_print_hook(printed_timings.append)
|
||||
|
||||
timer.start("cancelled")
|
||||
timer.cancel("cancelled")
|
||||
timer.print()
|
||||
|
||||
assert printed_timings == [{}]
|
||||
|
|
@ -48,6 +48,8 @@ class Timer:
|
|||
timing_dict = {}
|
||||
# sort by longest at top
|
||||
for timer_name, timings in sorted(self.timers.items(), key=lambda x: sum(x[1]), reverse=True):
|
||||
if not timings:
|
||||
continue
|
||||
avg_time = sum(timings) / len(timings)
|
||||
|
||||
if not is_ui:
|
||||
|
|
|
|||
Loading…
Reference in New Issue