Skip to content
Open
Changes from all commits
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
21 changes: 21 additions & 0 deletions Week04/decorators_busra_pehlivanlar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import time
import sys

def performance(func):
def wrapper(*args, **kwargs):
start_t = time.perf_counter()

result = func(*args, **kwargs)

end_t = time.perf_counter()

performance.counter += 1
performance.total_time += (end_t - start_t)
performance.total_mem += sys.getsizeof(result)

return result
return wrapper

performance.counter = 0
performance.total_time = 0.0
performance.total_mem = 0