MCPcopy Create free account
hub / github.com/modelscope/modelscope / check_time

Function check_time

modelscope/preprocessors/cv/timer.py:90–113  ·  view source on GitHub ↗

Add check points in a single line. This method is suitable for running a task on a list of items. A timer will be registered when the method is called for the first time. Example: >>> import time >>> import mmcv >>> for i in range(1, 6): >>> # simulate a code block

(timer_id)

Source from the content-addressed store, hash-verified

88
89
90def check_time(timer_id):
91 """Add check points in a single line.
92 This method is suitable for running a task on a list of items. A timer will
93 be registered when the method is called for the first time.
94 Example:
95
96 >>> import time
97 >>> import mmcv
98 >>> for i in range(1, 6):
99 >>> # simulate a code block
100 >>> time.sleep(i)
101 >>> mmcv.check_time('task1')
102 2.000
103 3.000
104 4.000
105 5.000
106 Args:
107 timer_id (str): Timer identifier.
108 """
109 if timer_id not in _g_timers:
110 _g_timers[timer_id] = Timer()
111 return 0
112 else:
113 return _g_timers[timer_id].since_last_check()

Callers 1

_should_evaluateMethod · 0.85

Calls 2

since_last_checkMethod · 0.80
TimerClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…