Created
July 15, 2020 13:21
-
-
Save sprytnyk/e3858fac74c4f50b82bb4ce1cef8ba49 to your computer and use it in GitHub Desktop.
A dummy function to measure time consumed by a function, method, etc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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