3 from __future__
import print_function
4 import re
, string
, sys
, os
, time
, math
8 (tp
, exp
) = ('compile', 'exec')
15 d
= re
.sub(r
',\d+:\d', '', d
)
17 r
= re
.findall(r
'TEST-(PASS|FAIL|RESULT.*?):\s+(.*?)\s+(.*?)\r*\n', d
)
25 if t
[0] == 'PASS' or t
[0] == 'FAIL' :
26 tmp
= t
[2].split('llvm-test/')
32 fname
= tmp
[1].strip('\r\n')
34 fname
= tmp
[0].strip('\r\n')
39 test
[fname
][t
[1] + ' state'] = t
[0]
40 test
[fname
][t
[1] + ' time'] = float('nan')
43 n
= t
[0].split('RESULT-')[1]
48 if n
== 'compile-success':
49 test
[fname
]['compile time'] = float(t
[2].split('program')[1].strip('\r\n'))
51 elif n
== 'exec-success':
52 test
[fname
]['exec time'] = float(t
[2].split('program')[1].strip('\r\n'))
54 print(test
[fname
][string
.replace(n
, '-success', '')])
65 # Diff results and look for regressions.
66 def diffResults(d_old
, d_new
):
71 for x
in ['compile state', 'compile time', 'exec state', 'exec time']:
75 for t
in sorted(d_old
.keys()) :
78 # Check if the test passed or failed.
79 for x
in ['compile state', 'compile time', 'exec state', 'exec time']:
81 if x
not in d_old
[t
] and x
not in d_new
[t
]:
87 if d_old
[t
][x
] == 'PASS':
88 if d_new
[t
][x
] != 'PASS':
89 regressions
[x
] += t
+ "\n"
91 if d_new
[t
][x
] == 'PASS':
95 regressions
[x
] += t
+ "\n"
97 if x
== 'compile state' or x
== 'exec state':
100 # For execution time, if there is no result it's a fail.
101 if x
not in d_old
[t
] and x
not in d_new
[t
]:
103 elif x
not in d_new
[t
]:
104 regressions
[x
] += t
+ "\n"
105 elif x
not in d_old
[t
]:
106 passes
[x
] += t
+ "\n"
108 if math
.isnan(d_old
[t
][x
]) and math
.isnan(d_new
[t
][x
]):
111 elif math
.isnan(d_old
[t
][x
]) and not math
.isnan(d_new
[t
][x
]):
112 passes
[x
] += t
+ "\n"
114 elif not math
.isnan(d_old
[t
][x
]) and math
.isnan(d_new
[t
][x
]):
115 regressions
[x
] += t
+ ": NaN%\n"
117 if d_new
[t
][x
] > d_old
[t
][x
] and d_old
[t
][x
] > 0.0 and \
118 (d_new
[t
][x
] - d_old
[t
][x
]) / d_old
[t
][x
] > .05:
119 regressions
[x
] += t
+ ": " + "{0:.1f}".format(100 * (d_new
[t
][x
] - d_old
[t
][x
]) / d_old
[t
][x
]) + "%\n"
124 if len(regressions
['compile state']) != 0:
125 print('REGRESSION: Compilation Failed')
126 print(regressions
['compile state'])
128 if len(regressions
['exec state']) != 0:
129 print('REGRESSION: Execution Failed')
130 print(regressions
['exec state'])
132 if len(regressions
['compile time']) != 0:
133 print('REGRESSION: Compilation Time')
134 print(regressions
['compile time'])
136 if len(regressions
['exec time']) != 0:
137 print('REGRESSION: Execution Time')
138 print(regressions
['exec time'])
140 if len(passes
['compile state']) != 0:
141 print('NEW PASSES: Compilation')
142 print(passes
['compile state'])
144 if len(passes
['exec state']) != 0:
145 print('NEW PASSES: Execution')
146 print(passes
['exec state'])
148 if len(removed
) != 0:
149 print('REMOVED TESTS')
153 if len(sys
.argv
) < 3 :
154 print('Usage:', sys
.argv
[0], '<old log> <new log>')
157 d_old
= parse(sys
.argv
[1])
158 d_new
= parse(sys
.argv
[2])
160 diffResults(d_old
, d_new
)