mirror of
https://github.com/Hizenberg469/Python-tutorial.git
synced 2026-04-19 23:12:24 +03:00
decorator finished
This commit is contained in:
@@ -108,4 +108,24 @@
|
||||
hello('hii')
|
||||
|
||||
|
||||
|
||||
|
||||
for ex:
|
||||
from time import time
|
||||
|
||||
def performance(fn):
|
||||
def wrapper(*args, **kwargs):
|
||||
t1 = time()
|
||||
result = fn(*args, **kwargs)
|
||||
t2 = time()
|
||||
print(f'took {t2-t1} ms')
|
||||
return result
|
||||
return wrapper
|
||||
|
||||
@performance
|
||||
def long_time():
|
||||
for i in range(1000000):
|
||||
i*5
|
||||
|
||||
long_time()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user