-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_demo_LogFun.py
More file actions
67 lines (51 loc) · 1.4 KB
/
test_demo_LogFun.py
File metadata and controls
67 lines (51 loc) · 1.4 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import time
from LogFun import traced, basicConfig, gzip_file
basicConfig(mode='file', logtype='normal', output='./logfun_output/', app_name="demo_LogFun")
@traced
def addAlpha(x, y):
a = 0.01
z = x + a * y
addAlpha._log('%s + %s * %s', (x, a, y))
return z
@traced
def multBeta(x):
multBeta._log('begin multBeta mult %s', x)
beta = 1
z = x * beta
multBeta._log('run multBeta z is %s', z)
multBeta._log('end multBeta successfully')
return z
@traced
def function_test():
begin_time = time.time() * 1000
a1 = 1
for i in range(10000):
a1 = addAlpha(a1, i)
a1 = multBeta(a1)
end_time = time.time() * 1000
print("Duration: %s", (end_time - begin_time))
return a1
@traced(methods=['add'], exclude=False)
class compute:
def __init__(self, x):
self._x = x
self.__log("initial a compute")
def add(self, y):
self._x = self._x + y
self.__log("add %s + %s", (self._x, y))
self._x = self.mul(self._x)
return self._x
def mul(self, y):
self._x = self._x * y
self.__log("mul %s * %s", (self._x, y))
return self._x
@traced
def class_test():
c = compute(1)
c = c.add(1)
class_test._log('compute is completed')
return c
#
if __name__ == '__main__':
function_test()
# class_test()