def __enter__(self):
parent = inspect.currentframe().f_back
try:
if parent.f_code.co_flags & inspect.CO_NEWLOCALS:
raise RuntimeError('timers only work when invoked at the module/script level')
self._with_start = parent.f_lasti
finally:
del parent
gc_enabled = gc.isenabled()
gc.disable()
self._gc_enabled = gc_enabled
self._start_time = self.time_function()
return self
评论列表
文章目录