measure instrumentation

This commit is contained in:
AF 2022-07-15 21:36:54 +03:00
parent 500f1df88c
commit 9e1d4aedd0

View File

@ -0,0 +1,17 @@
import time
from .instrumentation import Instrumentation
__all__ = ('Measure',)
class Measure(Instrumentation):
def __init__(self, target, methodname: str):
super().__init__(target, methodname)
self.log: list[float] = []
async def instrument(self, method, *args, **kwargs):
start = time.time()
result = await method(*args, **kwargs)
self.log.append(time.time() - start)
return result