blob: 7bd1523b58faa31c63fcfaaa6b1fbd1d51ae59e6 [file] [log] [blame]
Bill Wendlingf4594a32012-04-20 20:31:44 +00001#!/usr/bin/env python
Serge Guelton60ccceb2019-01-03 14:11:33 +00002
3from __future__ import print_function
Bill Wendling3a8eaa72011-10-20 00:45:46 +00004import re, string, sys, os, time, math
Duncan Sands067e2e22011-03-25 07:17:44 +00005
6DEBUG = 0
Duncan Sands067e2e22011-03-25 07:17:44 +00007
Bill Wendling3a8eaa72011-10-20 00:45:46 +00008(tp, exp) = ('compile', 'exec')
Duncan Sands067e2e22011-03-25 07:17:44 +00009
10def parse(file):
Bill Wendling3a8eaa72011-10-20 00:45:46 +000011 f = open(file, 'r')
Duncan Sands067e2e22011-03-25 07:17:44 +000012 d = f.read()
13
Bill Wendling3a8eaa72011-10-20 00:45:46 +000014 # Cleanup weird stuff
15 d = re.sub(r',\d+:\d', '', d)
16
Duncan Sands067e2e22011-03-25 07:17:44 +000017 r = re.findall(r'TEST-(PASS|FAIL|RESULT.*?):\s+(.*?)\s+(.*?)\r*\n', d)
Bill Wendling3a8eaa72011-10-20 00:45:46 +000018
Duncan Sands067e2e22011-03-25 07:17:44 +000019 test = {}
20 fname = ''
21 for t in r:
22 if DEBUG:
Serge Guelton60ccceb2019-01-03 14:11:33 +000023 print(t)
Bill Wendling3a8eaa72011-10-20 00:45:46 +000024
Duncan Sands067e2e22011-03-25 07:17:44 +000025 if t[0] == 'PASS' or t[0] == 'FAIL' :
Bill Wendling3a8eaa72011-10-20 00:45:46 +000026 tmp = t[2].split('llvm-test/')
Duncan Sands067e2e22011-03-25 07:17:44 +000027
28 if DEBUG:
Serge Guelton60ccceb2019-01-03 14:11:33 +000029 print(tmp)
Bill Wendling3a8eaa72011-10-20 00:45:46 +000030
Duncan Sands067e2e22011-03-25 07:17:44 +000031 if len(tmp) == 2:
32 fname = tmp[1].strip('\r\n')
33 else:
34 fname = tmp[0].strip('\r\n')
Bill Wendling3a8eaa72011-10-20 00:45:46 +000035
Serge Gueltonee72f592019-01-03 14:12:37 +000036 if fname not in test:
Duncan Sands067e2e22011-03-25 07:17:44 +000037 test[fname] = {}
Bill Wendling3a8eaa72011-10-20 00:45:46 +000038
39 test[fname][t[1] + ' state'] = t[0]
40 test[fname][t[1] + ' time'] = float('nan')
Duncan Sands067e2e22011-03-25 07:17:44 +000041 else :
42 try:
43 n = t[0].split('RESULT-')[1]
Bill Wendling3a8eaa72011-10-20 00:45:46 +000044
Duncan Sands067e2e22011-03-25 07:17:44 +000045 if DEBUG:
Serge Guelton60ccceb2019-01-03 14:11:33 +000046 print("n == ", n);
Duncan Sands067e2e22011-03-25 07:17:44 +000047
Bill Wendling3a8eaa72011-10-20 00:45:46 +000048 if n == 'compile-success':
49 test[fname]['compile time'] = float(t[2].split('program')[1].strip('\r\n'))
50
51 elif n == 'exec-success':
52 test[fname]['exec time'] = float(t[2].split('program')[1].strip('\r\n'))
Duncan Sands067e2e22011-03-25 07:17:44 +000053 if DEBUG:
Serge Guelton60ccceb2019-01-03 14:11:33 +000054 print(test[fname][string.replace(n, '-success', '')])
Bill Wendling3a8eaa72011-10-20 00:45:46 +000055
Duncan Sands067e2e22011-03-25 07:17:44 +000056 else :
Bill Wendling3a8eaa72011-10-20 00:45:46 +000057 # print "ERROR!"
Duncan Sands067e2e22011-03-25 07:17:44 +000058 sys.exit(1)
Bill Wendling3a8eaa72011-10-20 00:45:46 +000059
Duncan Sands067e2e22011-03-25 07:17:44 +000060 except:
61 continue
62
63 return test
64
65# Diff results and look for regressions.
66def diffResults(d_old, d_new):
Bill Wendlingb9ad6242011-10-21 06:58:01 +000067 regressions = {}
68 passes = {}
69 removed = ''
70
71 for x in ['compile state', 'compile time', 'exec state', 'exec time']:
72 regressions[x] = ''
73 passes[x] = ''
Duncan Sands067e2e22011-03-25 07:17:44 +000074
75 for t in sorted(d_old.keys()) :
Serge Gueltonee72f592019-01-03 14:12:37 +000076 if t in d_new:
Bill Wendling3a8eaa72011-10-20 00:45:46 +000077
Duncan Sands067e2e22011-03-25 07:17:44 +000078 # Check if the test passed or failed.
Bill Wendling3a8eaa72011-10-20 00:45:46 +000079 for x in ['compile state', 'compile time', 'exec state', 'exec time']:
80
Serge Gueltonee72f592019-01-03 14:12:37 +000081 if x not in d_old[t] and x not in d_new[t]:
Bill Wendling3a8eaa72011-10-20 00:45:46 +000082 continue
83
Serge Gueltonee72f592019-01-03 14:12:37 +000084 if x in d_old[t]:
85 if x in d_new[t]:
Bill Wendling3a8eaa72011-10-20 00:45:46 +000086
Duncan Sands067e2e22011-03-25 07:17:44 +000087 if d_old[t][x] == 'PASS':
88 if d_new[t][x] != 'PASS':
Bill Wendlingb9ad6242011-10-21 06:58:01 +000089 regressions[x] += t + "\n"
Duncan Sands067e2e22011-03-25 07:17:44 +000090 else:
91 if d_new[t][x] == 'PASS':
Bill Wendlingb9ad6242011-10-21 06:58:01 +000092 passes[x] += t + "\n"
Duncan Sands067e2e22011-03-25 07:17:44 +000093
Duncan Sands067e2e22011-03-25 07:17:44 +000094 else :
Bill Wendlingb9ad6242011-10-21 06:58:01 +000095 regressions[x] += t + "\n"
Bill Wendling3a8eaa72011-10-20 00:45:46 +000096
97 if x == 'compile state' or x == 'exec state':
98 continue
99
100 # For execution time, if there is no result it's a fail.
Serge Gueltonee72f592019-01-03 14:12:37 +0000101 if x not in d_old[t] and x not in d_new[t]:
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000102 continue
Serge Gueltonee72f592019-01-03 14:12:37 +0000103 elif x not in d_new[t]:
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000104 regressions[x] += t + "\n"
Serge Gueltonee72f592019-01-03 14:12:37 +0000105 elif x not in d_old[t]:
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000106 passes[x] += t + "\n"
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000107
108 if math.isnan(d_old[t][x]) and math.isnan(d_new[t][x]):
109 continue
110
111 elif math.isnan(d_old[t][x]) and not math.isnan(d_new[t][x]):
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000112 passes[x] += t + "\n"
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000113
114 elif not math.isnan(d_old[t][x]) and math.isnan(d_new[t][x]):
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000115 regressions[x] += t + ": NaN%\n"
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000116
Bill Wendling3df9f542011-10-21 06:26:01 +0000117 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:
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000119 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 +0000120
Duncan Sands067e2e22011-03-25 07:17:44 +0000121 else :
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000122 removed += t + "\n"
123
124 if len(regressions['compile state']) != 0:
Serge Guelton60ccceb2019-01-03 14:11:33 +0000125 print('REGRESSION: Compilation Failed')
126 print(regressions['compile state'])
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000127
128 if len(regressions['exec state']) != 0:
Serge Guelton60ccceb2019-01-03 14:11:33 +0000129 print('REGRESSION: Execution Failed')
130 print(regressions['exec state'])
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000131
132 if len(regressions['compile time']) != 0:
Serge Guelton60ccceb2019-01-03 14:11:33 +0000133 print('REGRESSION: Compilation Time')
134 print(regressions['compile time'])
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000135
136 if len(regressions['exec time']) != 0:
Serge Guelton60ccceb2019-01-03 14:11:33 +0000137 print('REGRESSION: Execution Time')
138 print(regressions['exec time'])
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000139
140 if len(passes['compile state']) != 0:
Serge Guelton60ccceb2019-01-03 14:11:33 +0000141 print('NEW PASSES: Compilation')
142 print(passes['compile state'])
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000143
144 if len(passes['exec state']) != 0:
Serge Guelton60ccceb2019-01-03 14:11:33 +0000145 print('NEW PASSES: Execution')
146 print(passes['exec state'])
Bill Wendlingb9ad6242011-10-21 06:58:01 +0000147
148 if len(removed) != 0:
Serge Guelton60ccceb2019-01-03 14:11:33 +0000149 print('REMOVED TESTS')
150 print(removed)
Duncan Sands067e2e22011-03-25 07:17:44 +0000151
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000152# Main
Duncan Sands067e2e22011-03-25 07:17:44 +0000153if len(sys.argv) < 3 :
Serge Guelton60ccceb2019-01-03 14:11:33 +0000154 print('Usage:', sys.argv[0], '<old log> <new log>')
Bill Wendling3a8eaa72011-10-20 00:45:46 +0000155 sys.exit(-1)
Duncan Sands067e2e22011-03-25 07:17:44 +0000156
157d_old = parse(sys.argv[1])
158d_new = parse(sys.argv[2])
159
Duncan Sands067e2e22011-03-25 07:17:44 +0000160diffResults(d_old, d_new)