Last active
October 28, 2021 05:36
-
-
Save nalaekaw/ac79bd3185a8816d907cfa1ea924fd81 to your computer and use it in GitHub Desktop.
Decorator - Execution time of a function
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
from time import time | |
def timing(func): | |
def wrapper(*args, **kwargs): | |
start_time = time() | |
result = func(*args, **kwargs) | |
end_time = time() | |
print( | |
f"Время выполнения функции '{func.__name__}' - " | |
f"{round(end_time-start_time, 3)} сек." | |
) | |
return result | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment