Skip to content

Commit 38d36ef

Browse files
authored
Create decorators_mehmet_balci.py
1 parent 2024d08 commit 38d36ef

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎Week04/decorators_mehmet_balci.py‎

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

0 commit comments

Comments
 (0)