From 01bed041183decb252b630b93fe9205b527fcc93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20Esat=20Ulu=C3=B6z?= <161027888+Ismail-Esat-Uluoz@users.noreply.github.com> Date: Sun, 5 Apr 2026 00:45:33 +0300 Subject: [PATCH] Create decorators_ismailesat_uluoz.py --- Week04/decorators_ismailesat_uluoz.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Week04/decorators_ismailesat_uluoz.py diff --git a/Week04/decorators_ismailesat_uluoz.py b/Week04/decorators_ismailesat_uluoz.py new file mode 100644 index 00000000..eba613bb --- /dev/null +++ b/Week04/decorators_ismailesat_uluoz.py @@ -0,0 +1,26 @@ +import tracemalloc +import time + +def performance(func): + + def wrapper(*args, **kwargs): + tracemalloc.start() + + start_time = time.perf_counter() + result = func(*args, **kwargs) + end_time = time.perf_counter() + + current, peak = tracemalloc.get_traced_memory() + tracemalloc.stop() + + wrapper.counter += 1 + wrapper.total_time += (end_time - start_time) + wrapper.total_mem += peak + + return result + + wrapper.counter = 0 + wrapper.total_time = 0.0 + wrapper.total_mem = 0 + + return wrapper