Skip to content

Instantly share code, notes, and snippets.

@Allwin12
Created April 18, 2022 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Allwin12/d0b27d3cda7f0acaf536ea8b36cd8cb5 to your computer and use it in GitHub Desktop.
Save Allwin12/d0b27d3cda7f0acaf536ea8b36cd8cb5 to your computer and use it in GitHub Desktop.
import time
def timer(func):
def wrapper(*args):
start_time = time.perf_counter()
func(*args)
print(f"The execution time is: {time.perf_counter() - start_time:.2f}s")
return wrapper
@timer
def some_function():
time.sleep(1)
@timer
def another_function():
time.sleep(2)
some_function()
another_function()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment