Bill Wendling | f4594a3 | 2012-04-20 20:31:44 +0000 | [diff] [blame^] | 1 | #!/usr/bin/env python |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 2 | import re, string, sys, os, time, math |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 3 | |
| 4 | DEBUG = 0 |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 5 | |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 6 | (tp, exp) = ('compile', 'exec') |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 7 | |
| 8 | def parse(file): |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 9 | f = open(file, 'r') |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 10 | d = f.read() |
| 11 | |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 12 | # Cleanup weird stuff |
| 13 | d = re.sub(r',\d+:\d', '', d) |
| 14 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 15 | 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] | 16 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 17 | test = {} |
| 18 | fname = '' |
| 19 | for t in r: |
| 20 | if DEBUG: |
| 21 | print t |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 22 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 23 | if t[0] == 'PASS' or t[0] == 'FAIL' : |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 24 | tmp = t[2].split('llvm-test/') |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 25 | |
| 26 | if DEBUG: |
| 27 | print tmp |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 28 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 29 | if len(tmp) == 2: |
| 30 | fname = tmp[1].strip('\r\n') |
| 31 | else: |
| 32 | fname = tmp[0].strip('\r\n') |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 33 | |
| 34 | if not test.has_key(fname): |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 35 | test[fname] = {} |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 36 | |
| 37 | test[fname][t[1] + ' state'] = t[0] |
| 38 | test[fname][t[1] + ' time'] = float('nan') |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 39 | else : |
| 40 | try: |
| 41 | n = t[0].split('RESULT-')[1] |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 42 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 43 | if DEBUG: |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 44 | print "n == ", n; |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 45 | |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 46 | 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 Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 51 | if DEBUG: |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 52 | print test[fname][string.replace(n, '-success', '')] |
| 53 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 54 | else : |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 55 | # print "ERROR!" |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 56 | sys.exit(1) |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 57 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 58 | except: |
| 59 | continue |
| 60 | |
| 61 | return test |
| 62 | |
| 63 | # Diff results and look for regressions. |
| 64 | def diffResults(d_old, d_new): |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 65 | 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 Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 72 | |
| 73 | for t in sorted(d_old.keys()) : |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 74 | if d_new.has_key(t): |
| 75 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 76 | # Check if the test passed or failed. |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 77 | 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 Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 82 | if d_old[t].has_key(x): |
| 83 | if d_new[t].has_key(x): |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 84 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 85 | if d_old[t][x] == 'PASS': |
| 86 | if d_new[t][x] != 'PASS': |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 87 | regressions[x] += t + "\n" |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 88 | else: |
| 89 | if d_new[t][x] == 'PASS': |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 90 | passes[x] += t + "\n" |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 91 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 92 | else : |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 93 | regressions[x] += t + "\n" |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 94 | |
| 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 Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 102 | regressions[x] += t + "\n" |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 103 | elif not d_old[t].has_key(x): |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 104 | passes[x] += t + "\n" |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 105 | |
| 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 Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 110 | passes[x] += t + "\n" |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 111 | |
| 112 | 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] | 113 | regressions[x] += t + ": NaN%\n" |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 114 | |
Bill Wendling | 3df9f54 | 2011-10-21 06:26:01 +0000 | [diff] [blame] | 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: |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 117 | 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] | 118 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 119 | else : |
Bill Wendling | b9ad624 | 2011-10-21 06:58:01 +0000 | [diff] [blame] | 120 | 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 Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 149 | |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 150 | # Main |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 151 | if len(sys.argv) < 3 : |
Bill Wendling | 3a8eaa7 | 2011-10-20 00:45:46 +0000 | [diff] [blame] | 152 | print 'Usage:', sys.argv[0], '<old log> <new log>' |
| 153 | sys.exit(-1) |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 154 | |
| 155 | d_old = parse(sys.argv[1]) |
| 156 | d_new = parse(sys.argv[2]) |
| 157 | |
Duncan Sands | 067e2e2 | 2011-03-25 07:17:44 +0000 | [diff] [blame] | 158 | diffResults(d_old, d_new) |