Skip to content

Instantly share code, notes, and snippets.

@Shalabyelectronics
Created November 16, 2022 05:31
Show Gist options
  • Save Shalabyelectronics/7b27a56f1516e9c68b6b8c2aab463840 to your computer and use it in GitHub Desktop.
Save Shalabyelectronics/7b27a56f1516e9c68b6b8c2aab463840 to your computer and use it in GitHub Desktop.
Decorator Check how long time does function to execute
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