Skip to content

Commit 3891d74

Browse files
authored
Update decorators_kayra_hokenek.py
1 parent 75aa2d9 commit 3891d74

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

‎Week04/decorators_kayra_hokenek.py‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
import tracemalloc
44

55
def performance(fn):
6-
76
@functools.wraps(fn)
87
def wrapper(*args, **kwargs):
9-
wrapper.counter += 1
8+
performance.counter += 1
109
tracemalloc.start()
1110
start = time.perf_counter()
1211

@@ -17,13 +16,13 @@ def wrapper(*args, **kwargs):
1716
current, peak = tracemalloc.get_traced_memory()
1817
tracemalloc.stop()
1918

20-
wrapper.total_time += elapsed
21-
wrapper.total_mem += peak
19+
performance.total_time += elapsed
20+
performance.total_mem += peak
2221

2322
return result
2423

25-
wrapper.counter = 0
26-
wrapper.total_time = 0.0
27-
wrapper.total_mem = 0
28-
2924
return wrapper
25+
26+
performance.counter = 0
27+
performance.total_time = 0.0
28+
performance.total_mem = 0

0 commit comments

Comments
 (0)