15 lines
368 B
Python
15 lines
368 B
Python
from .instrumentation import *
|
|
|
|
__all__ = ('Counter',)
|
|
|
|
|
|
class Counter(Instrumentation):
|
|
def __init__(self, target, methodname: str):
|
|
assert isinstance(methodname, str)
|
|
super().__init__(target, methodname)
|
|
self.counter = 0
|
|
|
|
def instrument(self, method, *args, **kwargs):
|
|
self.counter += 1
|
|
return method(*args, **kwargs)
|