Created
April 11, 2021 14:58
-
-
Save cristinelpopescu/9fd18a4f12b1ef3922fbefad3cd27c74 to your computer and use it in GitHub Desktop.
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
# decorator | |
from time import time | |
def performance(fn): | |
def wrapper (*args, **kawrgs): | |
t1 = time() | |
result = fn(*args, **kawrgs) | |
t2 = time() | |
print(f'took {t2 - t1} s') | |
return result | |
return wrapper | |
@performance | |
def long_time(): | |
for i in range(10000000): | |
i * 5 | |
long_time() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment