MCPcopy Create free account
hub / github.com/EryiXie/PlaneRecNet / stop

Function stop

utils/timer.py:76–105  ·  view source on GitHub ↗

If use_stack is True, this will stop the currently running timer and restore the previous timer on the stack if that exists. Note if use_stack is True, fn_name will be ignored. If use_stack is False, this will just stop timing the timer fn_name.

(fn_name=None, use_stack=True)

Source from the content-addressed store, hash-verified

74
75
76def stop(fn_name=None, use_stack=True):
77 """
78 If use_stack is True, this will stop the currently running timer and restore
79 the previous timer on the stack if that exists. Note if use_stack is True,
80 fn_name will be ignored.
81
82 If use_stack is False, this will just stop timing the timer fn_name.
83 """
84 global _running_timer, _disable_all
85
86 if _disable_all:
87 return
88
89 if use_stack:
90 if _running_timer is not None:
91 stop(_running_timer, use_stack=False)
92 if len(_timer_stack) > 0:
93 _running_timer = _timer_stack.pop()
94 start(_running_timer, use_stack=False)
95 else:
96 _running_timer = None
97 else:
98 print("Warning: timer stopped with no timer running!")
99 else:
100 if _start_times[fn_name] > -1:
101 ender.record()
102 ender.synchronize()
103 _total_times[fn_name] += starter.elapsed_time(ender)
104 else:
105 print("Warning: timer for %s stopped before starting!" % fn_name)
106
107
108def print_stats():

Callers 2

startFunction · 0.85
__exit__Method · 0.85

Calls 1

startFunction · 0.85

Tested by

no test coverage detected