Created
April 18, 2022 19:12
-
-
Save Allwin12/d0b27d3cda7f0acaf536ea8b36cd8cb5 to your computer and use it in GitHub Desktop.
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
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