We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 133e6cb + 8a17d3b commit 4966edcCopy full SHA for 4966edc
Week04/decorators_onur_konuk.py
@@ -0,0 +1,23 @@
1
+import time
2
+import tracemalloc
3
+
4
+def performance(func):
5
+ performance.counter = 0
6
+ performance.total_time = 0
7
+ performance.total_mem = 0
8
9
+ def wrapper(*args, **kwargs):
10
+ tracemalloc.start()
11
+ start_time = time.perf_counter()
12
+ result = func(*args, **kwargs)
13
+ end_time = time.perf_counter()
14
+ current, peak = tracemalloc.get_traced_memory()
15
+ tracemalloc.stop()
16
17
+ performance.counter += 1
18
+ performance.total_time += (end_time - start_time)
19
+ performance.total_mem += peak
20
21
+ return result
22
23
+ return wrapper
0 commit comments