Skip to content

Commit 7ecb05a

Browse files
Create decorators_aygul_ozkeklik.py
1 parent 24b3929 commit 7ecb05a

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)