From 1f9d25173f6278dda3f7cbff6319187dc2c93bb3 Mon Sep 17 00:00:00 2001 From: beytullaharslannn <151189674+beytullaharslannn@users.noreply.github.com> Date: Mon, 23 Mar 2026 17:02:36 +0300 Subject: [PATCH 1/3] Create decorators_beytullah_arslan.py --- Week04/decorators_beytullah_arslan.py | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Week04/decorators_beytullah_arslan.py diff --git a/Week04/decorators_beytullah_arslan.py b/Week04/decorators_beytullah_arslan.py new file mode 100644 index 00000000..9e4eb4f8 --- /dev/null +++ b/Week04/decorators_beytullah_arslan.py @@ -0,0 +1,29 @@ +import time +import tracemalloc + +def performance(func): + def wrapper(*args, **kwargs): + # 1. Ölçümleri Başlat + tracemalloc.start() + start_time = time.perf_counter() + + # 2. Asıl Fonksiyonu Çalıştır + result = func(*args, **kwargs) + + # 3. Ölçümleri Bitir + end_time = time.perf_counter() + current_mem, peak_mem = tracemalloc.get_traced_memory() + tracemalloc.stop() + + # 4. İstatistikleri Güncelle + wrapper.counter += 1 + wrapper.total_time += (end_time - start_time) + wrapper.total_mem += peak_mem + + return result + wrapper.counter = 0 + wrapper.total_time = 0.0 + wrapper.total_mem = 0 + + + return wrapper From 9e26a46f2922419c60ecbfdbba65abcc4b0b53b7 Mon Sep 17 00:00:00 2001 From: beytullaharslannn <151189674+beytullaharslannn@users.noreply.github.com> Date: Mon, 23 Mar 2026 17:07:03 +0300 Subject: [PATCH 2/3] Update decorators_beytullah_arslan.py --- Week04/decorators_beytullah_arslan.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Week04/decorators_beytullah_arslan.py b/Week04/decorators_beytullah_arslan.py index 9e4eb4f8..edcb80ac 100644 --- a/Week04/decorators_beytullah_arslan.py +++ b/Week04/decorators_beytullah_arslan.py @@ -24,6 +24,7 @@ def wrapper(*args, **kwargs): wrapper.counter = 0 wrapper.total_time = 0.0 wrapper.total_mem = 0 - + wrapper.__name__ = func.__name__ + wrapper.__doc__ = func.__doc__ return wrapper From f93c7fb09953b38784021e13567ac2a1936c8991 Mon Sep 17 00:00:00 2001 From: beytullaharslannn <151189674+beytullaharslannn@users.noreply.github.com> Date: Mon, 23 Mar 2026 17:16:15 +0300 Subject: [PATCH 3/3] Update2 decorators_beytullah_arslan.py --- Week04/decorators_beytullah_arslan.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Week04/decorators_beytullah_arslan.py b/Week04/decorators_beytullah_arslan.py index edcb80ac..3ac9f3fa 100644 --- a/Week04/decorators_beytullah_arslan.py +++ b/Week04/decorators_beytullah_arslan.py @@ -2,6 +2,10 @@ import tracemalloc def performance(func): + if not hasattr(performance, 'counter'): + performance.counter = 0 + performance.total_time = 0.0 + performance.total_mem = 0.0 def wrapper(*args, **kwargs): # 1. Ölçümleri Başlat tracemalloc.start() @@ -16,14 +20,11 @@ def wrapper(*args, **kwargs): tracemalloc.stop() # 4. İstatistikleri Güncelle - wrapper.counter += 1 - wrapper.total_time += (end_time - start_time) - wrapper.total_mem += peak_mem + performance.counter += 1 + performance.total_time += (end_time - start_time) + performance.total_mem += peak_mem return result - wrapper.counter = 0 - wrapper.total_time = 0.0 - wrapper.total_mem = 0 wrapper.__name__ = func.__name__ wrapper.__doc__ = func.__doc__