Skip to content

Instantly share code, notes, and snippets.

@TimothyLoyer
Created September 17, 2019 18:23
Show Gist options
  • Select an option

  • Save TimothyLoyer/bf4a53bcd4142828e1d7140f22afe1f3 to your computer and use it in GitHub Desktop.

Select an option

Save TimothyLoyer/bf4a53bcd4142828e1d7140f22afe1f3 to your computer and use it in GitHub Desktop.
Print Runtime Decorator
def print_runtime(func):
"""
Decorator to log the name and runtime in seconds for a callable.
:param func:
:return:
"""
def wrapper(*args, **kwargs):
start = timer()
value = func(*args, **kwargs)
logger.info("{:0.5f}s - {}".format(timer() - start, func.__name__))
return value
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment