blob: 8d3b4cfca29b8faa1ded45b772ae11453a4e3608 [file] [log] [blame]
Bill Wendlingf4594a32012-04-20 20:31:44 +00001#!/usr/bin/env python
Bill Wendling3a8eaa72011-10-20 00:45:46 +00002import re, string, sys, os, time, math
Duncan Sands067e2e22011-03-25 07:17:44 +00003
4DEBUG = 0
Duncan Sands067e2e22011-03-25 07:17:44 +00005
Bill Wendling3a8eaa72011-10-20 00:45:46 +00006(tp, exp) = ('compile', 'exec')
Duncan Sands067e2e22011-03-25 07:17:44 +00007
8def parse(file):
Bill Wendling3a8eaa72011-10-20 00:45:46 +00009 f = open(file, 'r')
Duncan Sands067e2e22011-03-25 07:17:44 +000010 d = f.read()
11
Bill Wendling3a8eaa72011-10-20 00:45:46 +000012 # Cleanup weird stuff
13 d = re.sub(r',\d+:\d', '', d)
14
Duncan Sands067e2e22011-03-25 07:17:44 +000015 r = re.findall(r'TEST-(PASS|FAIL|RESULT.*?):\s+(.*?)\s+(.*?)\r*\n', d)
Bill Wendling3a8eaa72011-10-20 00:45:46 +000016
Duncan Sands067e2e22011-03-25 07:17:44 +000017 test = {}
18 fname = ''
19 for t in r:
20 if DEBUG:
21 print t
Bill Wendling3a8eaa72011-10-20 00:45:46 +000022
Duncan Sands067e2e22011-03-25 07:17:44 +000023 if t[0] == 'PASS' or t[0] == 'FAIL' :
Bill Wendling3a8eaa72011-10-20 00:45:46 +000024 tmp = t[2].split('llvm-test/')
Duncan Sands067e2e22011-03-25 07:17:44 +000025
26 if DEBUG:
27 print tmp
Bill Wendling3a8eaa72011-10-20 00:45:46 +000028
Duncan Sands067e2e22011-03-25 07:17:44 +000029 if len(tmp) == 2:
30 fname = tmp[1].strip('\r\n')
31 else:
32 fname = tmp[0].strip('\r\n')
Bill Wendling3a8eaa72011-10-20 00:45:46 +000033
34 if not test.has_key(fname):
Duncan Sands067e2e22011-03-25 07:17:44 +000035 test[fname] = {}
Bill Wendling3a8eaa72011-10-20 00:45:46 +000036
37 test[fname][t[1] + ' state'] = t[0]
38 test[fname][t[1] + ' time'] = float('nan')
Duncan Sands067e2e22011-03-25 07:17:44 +000039 else :
40 try:
41 n = t[0].split('RESULT-')[1]
Bill Wendling3a8eaa72011-10-20 00:45:46 +000042
Duncan Sands067e2e22011-03-25 07:17:44 +000043 if DEBUG:
Bill Wendling3a8eaa72011-10-20 00:45:46 +000044 print "n == ", n;
Duncan Sands067e2e22011-03-25 07:17:44 +000045
Bill Wendling3a8eaa72011-10-20 00:45:46 +000046 if n == 'compile-success':
47 test[fname]['compile time'] = float(t[2].split('program')[1].strip('\r\n'))
48
49 elif n == 'exec-success':
50 test[fname]['exec time'] = float(t[2].split('program')[1].strip('\r\n'))
Duncan Sands067e2e22011-03-25 07:17:44 +000051 if DEBUG:
Bill Wendling3a8eaa72011-10-20 00:45:46 +000052 print test[fname][string.replace(n, '-success', '')]
53
Duncan Sands067e2e22011-03-25 07:17:44 +000054 else :
Bill Wendling3a8eaa72011-10-20 00:45:46 +000055 # print "ERROR!"
Duncan Sands067e2e22011-03-25 07:17:44 +000056 sys.exit(1)
Bill Wendling3a8eaa72011-10-20 00:45:46 +000057
Duncan Sands067e2e22011-03-25 07:17:44 +000058 except:
59 continue
60
61 return test
62
63# Diff results and look for regressions.
64def diffResults(d_old, d_new):
Bill Wendlingb9ad6242011-10-21 06:58:01 +000065 regressions = {}
66 passes = {}
67 removed = ''
68
69 for x in ['compile state', 'compile time', 'exec state', 'exec time']:
70 regressions[x] = ''
71 passes[x] = ''
Duncan Sands067e2e22011-03-25 07:17:44 +000072
73 for t in sorted(d_old.keys()) :
Bill Wendling3a8eaa72011-10-20 00:45:46 +000074 if d_new.has_key(t):
75
Duncan Sands067e2e22011-03-25 07:17:44 +000076 # Check if the test passed or failed.
Bill Wendling3a8eaa72011-10-20 00:45:46 +000077 for x in ['compile state', 'compile time', 'exec state', 'exec time']:
78
79 if not d_old[t].has_key(x) and not d_new[t].has_key(x):
80 continue
81
Duncan Sands067e2e22011-03-25 07:17:44 +000082 if d_old[t].has_key(x):
83 if d_new[t].has_key(x):
Bill Wendling3a8eaa72011-10-20 00:45:46 +000084
Duncan Sands067e2e22011-03-25 07:17:44 +000085 if d_old[t][x] == 'PASS':
86 if d_new[t][x] != 'PASS':
Bill Wendlingb9ad6242011-10-21 06:58:01 +000087 regressions[x] += t + "\n"
Duncan Sands067e2e22011-03-25 07:17:44 +000088 else:
89 if d_new[t][x] == 'PASS':
Bill Wendlingb9ad6242011-10-21 06:58:01 +000090 passes[x] += t + "\n"
Duncan Sands067e2e22011-03-25 07:17:44 +000091
Duncan Sands067e2e22011-03-25 07:17:44 +000092 else :
Bill Wendlingb9ad6242011-10-21 06:58:01 +000093 regressions[x] += t + "\n"
Bill Wendling3a8eaa72011-10-20 00:45:46 +000094
95 if x == 'compile state' or x == 'exec state':
96 continue
97
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):
100 continue
101 elif not d_new[t].has_key(x):
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000102 regressions[x] += t + "\n"
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000103 elif not d_old[t].has_key(x):
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000104 passes[x] += t + "\n"
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000105
106 if math.isnan(d_old[t][x]) and math.isnan(d_new[t][x]):
107 continue
108
109 elif math.isnan(d_old[t][x]) and not math.isnan(d_new[t][x]):
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000110 passes[x] += t + "\n"
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000111
112 elif not math.isnan(d_old[t][x]) and math.isnan(d_new[t][x]):
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000113 regressions[x] += t + ": NaN%\n"
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000114
Bill Wendling3df9f542011-10-21 06:26:01 +0000115 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:
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000117 regressions[x] += t + ": " + "{0:.1f}".format(100 * (d_new[t][x] - d_old[t][x]) / d_old[t][x]) + "%\n"
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000118
Duncan Sands067e2e22011-03-25 07:17:44 +0000119 else :
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000120 removed += t + "\n"
121
122 if len(regressions['compile state']) != 0:
123 print 'REGRESSION: Compilation Failed'
124 print regressions['compile state']
125
126 if len(regressions['exec state']) != 0:
127 print 'REGRESSION: Execution Failed'
128 print regressions['exec state']
129
130 if len(regressions['compile time']) != 0:
131 print 'REGRESSION: Compilation Time'
132 print regressions['compile time']
133
134 if len(regressions['exec time']) != 0:
135 print 'REGRESSION: Execution Time'
136 print regressions['exec time']
137
138 if len(passes['compile state']) != 0:
139 print 'NEW PASSES: Compilation'
140 print passes['compile state']
141
142 if len(passes['exec state']) != 0:
143 print 'NEW PASSES: Execution'
144 print passes['exec state']
145
146 if len(removed) != 0:
147 print 'REMOVED TESTS'
148 print removed
Duncan Sands067e2e22011-03-25 07:17:44 +0000149
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000150# Main
Duncan Sands067e2e22011-03-25 07:17:44 +0000151if len(sys.argv) < 3 :
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000152 print 'Usage:', sys.argv[0], '<old log> <new log>'
153 sys.exit(-1)
Duncan Sands067e2e22011-03-25 07:17:44 +0000154
155d_old = parse(sys.argv[1])
156d_new = parse(sys.argv[2])
157
Duncan Sands067e2e22011-03-25 07:17:44 +0000158diffResults(d_old, d_new)