3 from __future__
import print_function
4 import re
, string
, sys
, os
, time
, math
8 (tp
, exp
) = ("compile", "exec")
16 d
= re
.sub(r
",\d+:\d", "", d
)
18 r
= re
.findall(r
"TEST-(PASS|FAIL|RESULT.*?):\s+(.*?)\s+(.*?)\r*\n", d
)
26 if t
[0] == "PASS" or t
[0] == "FAIL":
27 tmp
= t
[2].split("llvm-test/")
33 fname
= tmp
[1].strip("\r\n")
35 fname
= tmp
[0].strip("\r\n")
40 test
[fname
][t
[1] + " state"] = t
[0]
41 test
[fname
][t
[1] + " time"] = float("nan")
44 n
= t
[0].split("RESULT-")[1]
49 if n
== "compile-success":
50 test
[fname
]["compile time"] = float(
51 t
[2].split("program")[1].strip("\r\n")
54 elif n
== "exec-success":
55 test
[fname
]["exec time"] = float(
56 t
[2].split("program")[1].strip("\r\n")
59 print(test
[fname
][string
.replace(n
, "-success", "")])
71 # Diff results and look for regressions.
72 def diffResults(d_old
, d_new
):
77 for x
in ["compile state", "compile time", "exec state", "exec time"]:
81 for t
in sorted(d_old
.keys()):
84 # Check if the test passed or failed.
85 for x
in ["compile state", "compile time", "exec state", "exec time"]:
87 if x
not in d_old
[t
] and x
not in d_new
[t
]:
93 if d_old
[t
][x
] == "PASS":
94 if d_new
[t
][x
] != "PASS":
95 regressions
[x
] += t
+ "\n"
97 if d_new
[t
][x
] == "PASS":
101 regressions
[x
] += t
+ "\n"
103 if x
== "compile state" or x
== "exec state":
106 # For execution time, if there is no result it's a fail.
107 if x
not in d_old
[t
] and x
not in d_new
[t
]:
109 elif x
not in d_new
[t
]:
110 regressions
[x
] += t
+ "\n"
111 elif x
not in d_old
[t
]:
112 passes
[x
] += t
+ "\n"
114 if math
.isnan(d_old
[t
][x
]) and math
.isnan(d_new
[t
][x
]):
117 elif math
.isnan(d_old
[t
][x
]) and not math
.isnan(d_new
[t
][x
]):
118 passes
[x
] += t
+ "\n"
120 elif not math
.isnan(d_old
[t
][x
]) and math
.isnan(d_new
[t
][x
]):
121 regressions
[x
] += t
+ ": NaN%\n"
124 d_new
[t
][x
] > d_old
[t
][x
]
125 and d_old
[t
][x
] > 0.0
126 and (d_new
[t
][x
] - d_old
[t
][x
]) / d_old
[t
][x
] > 0.05
132 100 * (d_new
[t
][x
] - d_old
[t
][x
]) / d_old
[t
][x
]
140 if len(regressions
["compile state"]) != 0:
141 print("REGRESSION: Compilation Failed")
142 print(regressions
["compile state"])
144 if len(regressions
["exec state"]) != 0:
145 print("REGRESSION: Execution Failed")
146 print(regressions
["exec state"])
148 if len(regressions
["compile time"]) != 0:
149 print("REGRESSION: Compilation Time")
150 print(regressions
["compile time"])
152 if len(regressions
["exec time"]) != 0:
153 print("REGRESSION: Execution Time")
154 print(regressions
["exec time"])
156 if len(passes
["compile state"]) != 0:
157 print("NEW PASSES: Compilation")
158 print(passes
["compile state"])
160 if len(passes
["exec state"]) != 0:
161 print("NEW PASSES: Execution")
162 print(passes
["exec state"])
164 if len(removed
) != 0:
165 print("REMOVED TESTS")
170 if len(sys
.argv
) < 3:
171 print("Usage:", sys
.argv
[0], "<old log> <new log>")
174 d_old
= parse(sys
.argv
[1])
175 d_new
= parse(sys
.argv
[2])
177 diffResults(d_old
, d_new
)