measure instrumentation
This commit is contained in:
parent
500f1df88c
commit
9e1d4aedd0
17
rainbowadn/instrument/_measure.py
Normal file
17
rainbowadn/instrument/_measure.py
Normal 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
|
Loading…
Reference in New Issue
Block a user