def timer(func):
    """Time a method and print its duration after return
    """
    name = func.__name__

    @wraps(func)
    def timed_func(self, *args, **kwargs):  # pylint: disable=missing-docstring
        _start = time.time()
        out = func(self, *args, **kwargs)
        self.log(2, '{0} took {1:.1f} sec'.format(name, time.time() - _start))
        return out

    return timed_func
def timer ( func ) : name = func . __name__ @ wraps ( func ) def timed_func ( self , * args , ** kwargs ) : _start = time . time ( ) out = func ( self , * args , ** kwargs ) self . log ( 2 , '{0} took {1:.1f} sec' . format ( name , time . time ( ) - _start ) ) return out return timed_func
Time a method and print its duration after return