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)
| 88 | |
| 89 | |
| 90 | def 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() |
no test coverage detected
searching dependent graphs…