-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestcase.py
84 lines (75 loc) · 1.15 KB
/
testcase.py
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import time
import profily
def main():
t01();
t03()
t04();
t05()
t03();
t01()
t06();
return ()
def t04():
print "# t04"
def workgen():
for i in range(4):
n = "zzz%s"%i
x = {}
exec "def "+n+"(): slow("+str(i)+")" in globals(), x
zzz = x[n]
yield zzz
for work in workgen():
work()
return "# t04"
def t05():
print "# t05"
def genwork():
t03()
for i in range(5):
def zzz():
t7x02()
yield zzz
def wrapper(g):
t03()
try:
while True:
l = g.next()
l()
def z(): t01()
yield z
except:
pass
for work in wrapper(genwork()):
work()
return "# t05"
def t06():
print "# t06"
s = 3.0
while s > 0:
s = s/2.
busy(s)
return "# t06"
def t01():
print "# t01 1"
busy(0.1)
return "# t01"
def t7x02():
busy(0.2)
def slow(i):
busy(0.01*i)
def t03():
print "# t03"
busy(0.3)
return "# t03"
def busy(delay):
t = time.time
t0 = t1 = t()
a = []
while t1-t0<=delay:
t1 = t()
a.insert(0,t1)
del a[20:]
if __name__ == '__main__':
prof = profily.Profile()
prof.run('main()')
profily.Stats(prof,threshold=0.01).strip_dirs().sort_stats('cumulative').dot_callers()