Skip to content

Commit 2d45101

Browse files
W5HWV4V2
1 parent 7298b0e commit 2d45101

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎Week04/decorators_umut_turk.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import time
2+
import tracemalloc
3+
4+
def performance(f):
5+
def _performance():
6+
if not hasattr(_performance, "counter"):
7+
counter = 0
8+
_performance.counter += 1
9+
x = time.time()
10+
tracemalloc.start()
11+
f()
12+
total_mem = tracemalloc.get_traced_memory
13+
total_time = time.time() - x
14+
tracemalloc.stop

0 commit comments

Comments
 (0)