Skip to content

Commit 4f6bca8

Browse files
authored
decorators_muhammet_topcu
1 parent 71f5b39 commit 4f6bca8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import time
2+
import sys
3+
4+
def performance(func):
5+
def wrapper(*args, **kwargs):
6+
start = time.time()
7+
result = func(*args, **kwargs)
8+
end = time.time()
9+
10+
performance.counter += 1
11+
performance.total_time += end - start
12+
13+
try:
14+
performance.total_mem += sys.getsizeof(result)
15+
except Exception:
16+
pass
17+
18+
return result
19+
20+
return wrapper
21+
22+
performance.counter = 0
23+
performance.total_time = 0.0
24+
performance.total_mem = 0

0 commit comments

Comments
 (0)