()
return decorator
Decorator to get timing information on a class method

    The class must have a TimingContext instance as self.timing_context
Decorator to get timing information on a class method
Decorator to get timing information on a class method
def time_method():
    """Decorator to get timing information on a class method

    The class must have a TimingContext instance as self.timing_context
    """
    def decorator(fn):
        @wraps(fn)
        def _inner(self, *args, **kwargs):
            if self.timing_context.is_started():
                tag = f"{type(self).__name__}.{fn.__name__}"
                with self.timing_context(tag):
                    return fn(self, *args, **kwargs)
            else:
                return fn(self, *args, **kwargs)
        return _inner
    return decorator
def time_method ( ) : def decorator ( fn ) : @ wraps ( fn ) def _inner ( self , * args , * * kwargs ) : if self . timing_context . is_started ( ) : tag = f"{type(self).__name__}.{fn.__name__}" with self . timing_context ( tag ) : return fn ( self , * args , * * kwargs ) else : return fn ( self , * args , * * kwargs ) return _inner return decorator