Timer¶
- class mmengine.utils.Timer(start=True, print_tmpl=None)[source]¶
A flexible Timer class.
Examples
>>> import time >>> import mmcv >>> with mmcv.Timer(): >>> # simulate a code block that will run for 1s >>> time.sleep(1) 1.000 >>> with mmcv.Timer(print_tmpl='it takes {:.1f} seconds'): >>> # simulate a code block that will run for 1s >>> time.sleep(1) it takes 1.0 seconds >>> timer = mmcv.Timer() >>> time.sleep(0.5) >>> print(timer.since_start()) 0.500 >>> time.sleep(0.5) >>> print(timer.since_last_check()) 0.500 >>> print(timer.since_start()) 1.000
- since_last_check()[source]¶
Time since the last checking.
Either
since_start()
orsince_last_check()
is a checking operation.- Returns:
Time in seconds.
- Return type: