Bill Wendling | f4594a3 | 2012-04-20 20:31:44 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
Serge Guelton | 60ccceb | 2019-01-03 14:11:33 +0000 | [diff] [blame] | 2 | |
| 3 | from __future__ import print_function |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 4 | import re, string, sys, os, time, math |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 5 | |
| 6 | DEBUG = 0 |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 7 | |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 8 | (tp, exp) = ('compile', 'exec') |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 9 | |
| 10 | def parse(file): |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 11 | f = open(file, 'r') |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 12 | d = f.read() |
| 13 | |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 14 | # Cleanup weird stuff |
| 15 | d = re.sub(r',\d+:\d', '', d) |
| 16 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 17 | r = re.findall(r'TEST-(PASS|FAIL|RESULT.*?):\s+(.*?)\s+(.*?)\r*\n', d) |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 18 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 19 | test = {} |
| 20 | fname = '' |
| 21 | for t in r: |
| 22 | if DEBUG: |
Serge Guelton | 60ccceb | 2019-01-03 14:11:33 +0000 | [diff] [blame] | 23 | print(t) |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 24 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 25 | if t[0] == 'PASS' or t[0] == 'FAIL' : |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 26 | tmp = t[2].split('llvm-test/') |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 27 | |
| 28 | if DEBUG: |
Serge Guelton | 60ccceb | 2019-01-03 14:11:33 +0000 | [diff] [blame] | 29 | print(tmp) |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 30 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 31 | if len(tmp) == 2: |
| 32 | fname = tmp[1].strip('\r\n') |
| 33 | else: |
| 34 | fname = tmp[0].strip('\r\n') |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 35 | |
Serge Guelton | ee72f59 | 2019-01-03 14:12:37 +0000 | [diff] [blame] | 36 | if fname not in test: |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 37 | test[fname] = {} |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 38 | |
| 39 | test[fname][t[1] + ' state'] = t[0] |
| 40 | test[fname][t[1] + ' time'] = float('nan') |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 41 | else : |
| 42 | try: |
| 43 | n = t[0].split('RESULT-')[1] |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 44 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 45 | if DEBUG: |
Serge Guelton | 60ccceb | 2019-01-03 14:11:33 +0000 | [diff] [blame] | 46 | print("n == ", n); |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 47 | |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 48 | 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 Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 53 | if DEBUG: |
Serge Guelton | 60ccceb | 2019-01-03 14:11:33 +0000 | [diff] [blame] | 54 | print(test[fname][string.replace(n, '-success', '')]) |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 55 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 56 | else : |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 57 | # print "ERROR!" |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 58 | sys.exit(1) |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 59 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 60 | except: |
| 61 | continue |
| 62 | |
| 63 | return test |
| 64 | |
| 65 | # Diff results and look for regressions. |
| 66 | def diffResults(d_old, d_new): |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 67 | 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 Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 74 | |
| 75 | for t in sorted(d_old.keys()) : |
Serge Guelton | ee72f59 | 2019-01-03 14:12:37 +0000 | [diff] [blame] | 76 | if t in d_new: |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 77 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 78 | # Check if the test passed or failed. |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 79 | for x in ['compile state', 'compile time', 'exec state', 'exec time']: |
| 80 | |
Serge Guelton | ee72f59 | 2019-01-03 14:12:37 +0000 | [diff] [blame] | 81 | if x not in d_old[t] and x not in d_new[t]: |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 82 | continue |
| 83 | |
Serge Guelton | ee72f59 | 2019-01-03 14:12:37 +0000 | [diff] [blame] | 84 | if x in d_old[t]: |
| 85 | if x in d_new[t]: |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 86 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 87 | if d_old[t][x] == 'PASS': |
| 88 | if d_new[t][x] != 'PASS': |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 89 | regressions[x] += t + "\n" |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 90 | else: |
| 91 | if d_new[t][x] == 'PASS': |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 92 | passes[x] += t + "\n" |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 93 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 94 | else : |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 95 | regressions[x] += t + "\n" |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 96 | |
| 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 Guelton | ee72f59 | 2019-01-03 14:12:37 +0000 | [diff] [blame] | 101 | if x not in d_old[t] and x not in d_new[t]: |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 102 | continue |
Serge Guelton | ee72f59 | 2019-01-03 14:12:37 +0000 | [diff] [blame] | 103 | elif x not in d_new[t]: |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 104 | regressions[x] += t + "\n" |
Serge Guelton | ee72f59 | 2019-01-03 14:12:37 +0000 | [diff] [blame] | 105 | elif x not in d_old[t]: |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 106 | passes[x] += t + "\n" |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 107 | |
| 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 Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 112 | passes[x] += t + "\n" |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 113 | |
| 114 | elif not math.isnan(d_old[t][x]) and math.isnan(d_new[t][x]): |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 115 | regressions[x] += t + ": NaN%\n" |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 116 | |
Bill Wendling | 3df9f54 | 2011-10-21 06:26:01 +0000 | [diff] [blame] | 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: |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 119 | regressions[x] += t + ": " + "{0:.1f}".format(100 * (d_new[t][x] - d_old[t][x]) / d_old[t][x]) + "%\n" |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 120 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 121 | else : |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 122 | removed += t + "\n" |
| 123 | |
| 124 | if len(regressions['compile state']) != 0: |
Serge Guelton | 60ccceb | 2019-01-03 14:11:33 +0000 | [diff] [blame] | 125 | print('REGRESSION: Compilation Failed') |
| 126 | print(regressions['compile state']) |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 127 | |
| 128 | if len(regressions['exec state']) != 0: |
Serge Guelton | 60ccceb | 2019-01-03 14:11:33 +0000 | [diff] [blame] | 129 | print('REGRESSION: Execution Failed') |
| 130 | print(regressions['exec state']) |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 131 | |
| 132 | if len(regressions['compile time']) != 0: |
Serge Guelton | 60ccceb | 2019-01-03 14:11:33 +0000 | [diff] [blame] | 133 | print('REGRESSION: Compilation Time') |
| 134 | print(regressions['compile time']) |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 135 | |
| 136 | if len(regressions['exec time']) != 0: |
Serge Guelton | 60ccceb | 2019-01-03 14:11:33 +0000 | [diff] [blame] | 137 | print('REGRESSION: Execution Time') |
| 138 | print(regressions['exec time']) |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 139 | |
| 140 | if len(passes['compile state']) != 0: |
Serge Guelton | 60ccceb | 2019-01-03 14:11:33 +0000 | [diff] [blame] | 141 | print('NEW PASSES: Compilation') |
| 142 | print(passes['compile state']) |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 143 | |
| 144 | if len(passes['exec state']) != 0: |
Serge Guelton | 60ccceb | 2019-01-03 14:11:33 +0000 | [diff] [blame] | 145 | print('NEW PASSES: Execution') |
| 146 | print(passes['exec state']) |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 147 | |
| 148 | if len(removed) != 0: |
Serge Guelton | 60ccceb | 2019-01-03 14:11:33 +0000 | [diff] [blame] | 149 | print('REMOVED TESTS') |
| 150 | print(removed) |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 151 | |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 152 | # Main |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 153 | if len(sys.argv) < 3 : |
Serge Guelton | 60ccceb | 2019-01-03 14:11:33 +0000 | [diff] [blame] | 154 | print('Usage:', sys.argv[0], '<old log> <new log>') |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 155 | sys.exit(-1) |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 156 | |
| 157 | d_old = parse(sys.argv[1]) |
| 158 | d_new = parse(sys.argv[2]) |
| 159 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 160 | diffResults(d_old, d_new) |