Skip to content

Commit cb9c7b2

Browse files
authored
Create decorators_zeynepnur_erten.py
1 parent 2024d08 commit cb9c7b2

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import time
2+
import tracemalloc
3+
4+
def performance(func):
5+
def wrapper(*args, **kwargs):
6+
tracemalloc.start()
7+
initial =time.perf_counter()
8+
result = func(*args, **kwargs)
9+
end = time.perf_counter()
10+
11+
current, peak = tracemalloc.get_traced_memory()
12+
tracemalloc.stop()
13+
14+
performance.counter +=1
15+
performance.total_time +=end-initial
16+
performance.total_mem += peak
17+
18+
return result
19+
return wrapper
20+
21+
performance.counter = 0
22+
performance.total_time = 0
23+
performance.total_mem = 0

0 commit comments

Comments
 (0)