Stopwatch

class deepfos.lib.stopwatch.Stopwatch(unit='ns', sink=<bound method Logger.info of <loguru.logger handlers=[(id=0, level=10, sink=<stderr>)]>>)

计时器

参数
  • unit (str) – 计时单位

  • sink – 耗时信息的输出函数,默认为 logger.info

>>> watch = Stopwatch(unit='s', sink=print)
>>> import time
>>> with watch('[task - sleep]'):
...    time.sleep(0)
[task - sleep]:0.00s
Exclude-members

计时器

Args:

unit: 计时单位 sink: 耗时信息的输出函数,默认为 logger.info

>>> watch = Stopwatch(unit='s', sink=print)
>>> import time
>>> with watch('[task - sleep]'):
...    time.sleep(0)
[task - sleep]:0.00s