Created
November 16, 2022 05:31
-
-
Save Shalabyelectronics/7b27a56f1516e9c68b6b8c2aab463840 to your computer and use it in GitHub Desktop.
Decorator Check how long time does function to execute
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
def calc_execution(func): | |
def wrapper(*args,**kwargs): | |
""" | |
This wrapper will use time module to check | |
the diffrence between the time when the excution start | |
and when it's end. | |
""" | |
import time | |
start = time.time() | |
value = func(*args,**kwargs) | |
end = time.time() | |
print(f"\033[32m>>Total time {func.__name__} Function need to excute is :\033[0m \033[93m{(end - start):.3f}\033[0m \033[32mseconds<<\033[0m\n") | |
return value | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment