Created
October 19, 2019 03:57
-
-
Save adrianmarkperea/6faba6404880a6ae67f20a37b48a9eb8 to your computer and use it in GitHub Desktop.
This file contains 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 time | |
def time_it(fun): | |
def wrapper(*args, **kwargs): | |
start = time.time() | |
res = fun(*args, **kwargs) | |
end = time.time() | |
print(f'Function took {end-start}s') | |
return res | |
return wrapper | |
@time_it | |
def waste_time(): | |
for i in range(10000000): | |
pass | |
waste_time() | |
# Output | |
Function took 0.18418407440185547s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment