-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimer.py
More file actions
37 lines (35 loc) · 699 Bytes
/
Timer.py
File metadata and controls
37 lines (35 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# def decorator(func):
# def wrapper(*args, **kwargs):
# return func(*args, **kwargs)
# return wrapper
# def g(a=[]):
# a.append(1)
# print(a)
# h = decorator(g)
# g()
# h()
# def decorate(func):
# def wrapper(*args, **kwargs):
# func(*args, **kwargs)
# print(args, kwargs)
# return wrapper
# def f(a=[5], b=[6]):
# print(a, b)
# a.append(3)
# b.append(4)
# f = decorate(f)
# f([1], b=[2])
# f([1], b=[2])
import time
def timer(func):
def wrapper(*args, **kwargs):
a = time.time()
output =
b =
print a - b
return output
return wrapper
def f(a, b):
return a + b
f = timer(f)
f(1, 2)