Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create decorators_umut_azazi.py #208

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Week03/decorators_umut_azazi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import time
import sys

def performance(func):
def wrapper(*args, **kwargs):
if not hasattr(wrapper, 'counter'):
wrapper.counter = 0
wrapper.total_time = 0
wrapper.total_mem = 0

wrapper.counter += 1

start_time = time.time()
start_mem = sys.getsizeof(func)
result = func(*args, **kwargs)
total_time = time.time() - start_time
total_mem = sys.getsizeof(result) - start_mem

wrapper.total_time += total_time
wrapper.total_mem += total_mem



return result
return wrapper

Loading