diff --git a/rainbowadn/instrument/_measure.py b/rainbowadn/instrument/_measure.py new file mode 100644 index 0000000..a7b6901 --- /dev/null +++ b/rainbowadn/instrument/_measure.py @@ -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