mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
Forgotten file added
This commit is contained in:
13
performance/context_managers.py
Normal file
13
performance/context_managers.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import time
|
||||
|
||||
from contextlib import contextmanager
|
||||
|
||||
|
||||
@contextmanager
|
||||
def time_to_logger(logger, msg):
|
||||
t0 = time.time()
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
took = (time.time() - t0) * 1000
|
||||
logger.info(f"{took:6.2f}ms {msg}")
|
||||
Reference in New Issue
Block a user