Skip to content

Instantly share code, notes, and snippets.

@nalaekaw
Last active October 28, 2021 05:36
Show Gist options
  • Save nalaekaw/ac79bd3185a8816d907cfa1ea924fd81 to your computer and use it in GitHub Desktop.
Save nalaekaw/ac79bd3185a8816d907cfa1ea924fd81 to your computer and use it in GitHub Desktop.
Decorator - Execution time of a function
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