Skip to content

Instantly share code, notes, and snippets.

@britonad
Created July 15, 2020 13:21
Show Gist options
  • Save britonad/e3858fac74c4f50b82bb4ce1cef8ba49 to your computer and use it in GitHub Desktop.
Save britonad/e3858fac74c4f50b82bb4ce1cef8ba49 to your computer and use it in GitHub Desktop.
A dummy function to measure time consumed by a function, method, etc.
import resource
from functools import wraps
from time import time
def time_it(func):
@wraps(func)
def wrapper(*args, **kwargs):
start = time()
f = func(*args, **kwargs)
end = time()
print('Took time: {:.5f}'.format(end - start))
return f
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment