2 import re, string, sys, os, time, math
6 (tp, exp) = ('compile', 'exec')
13 d = re.sub(r',\d+:\d', '', d)
15 r = re.findall(r'TEST-(PASS|FAIL|RESULT.*?):\s+(.*?)\s+(.*?)\r*\n', d)
23 if t[0] == 'PASS' or t[0] == 'FAIL' :
24 tmp = t[2].split('llvm-test/')
30 fname = tmp[1].strip('\r\n')
32 fname = tmp[0].strip('\r\n')
34 if not test.has_key(fname):
37 test[fname][t[1] + ' state'] = t[0]
38 test[fname][t[1] + ' time'] = float('nan')
41 n = t[0].split('RESULT-')[1]
46 if n == 'compile-success':
47 test[fname]['compile time'] = float(t[2].split('program')[1].strip('\r\n'))
49 elif n == 'exec-success':
50 test[fname]['exec time'] = float(t[2].split('program')[1].strip('\r\n'))
52 print test[fname][string.replace(n, '-success', '')]
63 # Diff results and look for regressions.
64 def diffResults(d_old, d_new):
69 for x in ['compile state', 'compile time', 'exec state', 'exec time']:
73 for t in sorted(d_old.keys()) :
76 # Check if the test passed or failed.
77 for x in ['compile state', 'compile time', 'exec state', 'exec time']:
79 if not d_old[t].has_key(x) and not d_new[t].has_key(x):
82 if d_old[t].has_key(x):
83 if d_new[t].has_key(x):
85 if d_old[t][x] == 'PASS':
86 if d_new[t][x] != 'PASS':
87 regressions[x] += t + "\n"
89 if d_new[t][x] == 'PASS':
93 regressions[x] += t + "\n"
95 if x == 'compile state' or x == 'exec state':
98 # For execution time, if there is no result it's a fail.
99 if not d_old[t].has_key(x) and not d_new[t].has_key(x):
101 elif not d_new[t].has_key(x):
102 regressions[x] += t + "\n"
103 elif not d_old[t].has_key(x):
104 passes[x] += t + "\n"
106 if math.isnan(d_old[t][x]) and math.isnan(d_new[t][x]):
109 elif math.isnan(d_old[t][x]) and not math.isnan(d_new[t][x]):
110 passes[x] += t + "\n"
112 elif not math.isnan(d_old[t][x]) and math.isnan(d_new[t][x]):
113 regressions[x] += t + ": NaN%\n"
115 if d_new[t][x] > d_old[t][x] and d_old[t][x] > 0.0 and \
116 (d_new[t][x] - d_old[t][x]) / d_old[t][x] > .05:
117 regressions[x] += t + ": " + "{0:.1f}".format(100 * (d_new[t][x] - d_old[t][x]) / d_old[t][x]) + "%\n"
122 if len(regressions['compile state']) != 0:
123 print 'REGRESSION: Compilation Failed'
124 print regressions['compile state']
126 if len(regressions['exec state']) != 0:
127 print 'REGRESSION: Execution Failed'
128 print regressions['exec state']
130 if len(regressions['compile time']) != 0:
131 print 'REGRESSION: Compilation Time'
132 print regressions['compile time']
134 if len(regressions['exec time']) != 0:
135 print 'REGRESSION: Execution Time'
136 print regressions['exec time']
138 if len(passes['compile state']) != 0:
139 print 'NEW PASSES: Compilation'
140 print passes['compile state']
142 if len(passes['exec state']) != 0:
143 print 'NEW PASSES: Execution'
144 print passes['exec state']
146 if len(removed) != 0:
147 print 'REMOVED TESTS'
151 if len(sys.argv) < 3 :
152 print 'Usage:', sys.argv[0], '<old log> <new log>'
155 d_old = parse(sys.argv[1])
156 d_new = parse(sys.argv[2])
158 diffResults(d_old, d_new)