Skip to content

Commit b704f39

Browse files
committed
bug fixing
1 parent 5ca3ddf commit b704f39

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Week04/decorators_tarik_bozgan.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@
44
def performance(func):
55
def wrapper(*args, **kwargs):
66
tracemalloc.start()
7-
start = time.perf_counter()
7+
t1 = time.perf_counter()
88

99
result = func(*args, **kwargs)
1010

11-
end = time.perf_counter()
12-
current, peak = tracemalloc.get_traced_memory()
11+
t2 = time.perf_counter()
12+
_, peak = tracemalloc.get_traced_memory()
1313
tracemalloc.stop()
1414

15-
wrapper.counter += 1
16-
wrapper.total_time += (end - start)
17-
wrapper.total_mem += peak
15+
# Hata buradaydı: Sayaçları wrapper'a değil, performance fonksiyonuna ekliyoruz
16+
performance.counter += 1
17+
performance.total_time += (t2 - t1)
18+
performance.total_mem += peak
1819

1920
return result
21+
return wrapper
2022

21-
wrapper.counter = 0
22-
wrapper.total_time = 0
23-
wrapper.total_mem = 0
24-
25-
return wrapper
23+
# Testin beklediği özellikler (Attributes) ana fonksiyona atanmalı
24+
performance.counter = 0
25+
performance.total_time = 0
26+
performance.total_mem = 0

0 commit comments

Comments
 (0)