Skip to content

Instantly share code, notes, and snippets.

@cristinelpopescu
Created April 11, 2021 14:58
Show Gist options
  • Save cristinelpopescu/9fd18a4f12b1ef3922fbefad3cd27c74 to your computer and use it in GitHub Desktop.
Save cristinelpopescu/9fd18a4f12b1ef3922fbefad3cd27c74 to your computer and use it in GitHub Desktop.
# 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