Commit b7ac3668 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[tools] perf-compare.py is now able to combine multiple json results into one column.

Currently, the overlapping results of individual benchmark tests are overwritten.

Example:
  tools/perf-compare.py Result,ss.json,kr.json Master,kr-m.json,ss-m.json -o compare.html
or
  tools/perf-compare.py Result,ss.json Result,kr.json Master,kr-m.json Master,ss-m.json -o compare.html

BUG=v8:6144
NOTRY=true

Change-Id: Ia340e8c01c46da17b1f4eee6c6bb8e5e9bb12c3e
Reviewed-on: https://chromium-review.googlesource.com/459537
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44090}
parent c152d459
...@@ -198,14 +198,14 @@ class ResultTableRenderer: ...@@ -198,14 +198,14 @@ class ResultTableRenderer:
print(string_data) print(string_data)
def bold(self, data): def bold(self, data):
return "<b>" + data + "</b>" return "<b>%s</b>" % data
def red(self, data): def red(self, data):
return "<font color=\"red\">" + data + "</font>" return "<font color=\"red\">%s</font>" % data
def green(self, data): def green(self, data):
return "<font color=\"green\">" + data + "</font>" return "<font color=\"green\">%s</font>" % data
def PrintHeader(self): def PrintHeader(self):
data = """<html> data = """<html>
...@@ -304,10 +304,13 @@ table tr th { ...@@ -304,10 +304,13 @@ table tr th {
} }
table tr td { table tr td {
border: 1px solid #cccccc; border: 1px solid #cccccc;
text-align: left; text-align: right;
margin: 0; margin: 0;
padding: 6px 13px; padding: 6px 13px;
} }
table tr td.name-column {
text-align: left;
}
table tr th :first-child, table tr td :first-child { table tr th :first-child, table tr td :first-child {
margin-top: 0; margin-top: 0;
} }
...@@ -322,15 +325,15 @@ table tr th :last-child, table tr td :last-child { ...@@ -322,15 +325,15 @@ table tr th :last-child, table tr td :last-child {
def StartSuite(self, suite_name, run_names): def StartSuite(self, suite_name, run_names):
self.Print("<h2>") self.Print("<h2>")
self.Print("<a name=\"" + suite_name + "\">" + self.Print("<a name=\"%s\">%s</a> <a href=\"#top\">(top)</a>" %
suite_name + "</a> <a href=\"#top\">(top)</a>") (suite_name, suite_name))
self.Print("</h2>"); self.Print("</h2>");
self.Print("<table class=\"benchmark\">") self.Print("<table class=\"benchmark\">")
self.Print("<thead>") self.Print("<thead>")
self.Print(" <th>Test</th>") self.Print(" <th>Test</th>")
main_run = None main_run = None
for run_name in run_names: for run_name in run_names:
self.Print(" <th>" + run_name + "</th>") self.Print(" <th>%s</th>" % run_name)
if main_run == None: if main_run == None:
main_run = run_name main_run = run_name
else: else:
...@@ -346,7 +349,7 @@ table tr th :last-child, table tr td :last-child { ...@@ -346,7 +349,7 @@ table tr th :last-child, table tr td :last-child {
def StartBenchmark(self, benchmark_name): def StartBenchmark(self, benchmark_name):
self.Print(" <tr>") self.Print(" <tr>")
self.Print(" <td>" + benchmark_name + "</td>") self.Print(" <td class=\"name-column\">%s</td>" % benchmark_name)
def FinishBenchmark(self): def FinishBenchmark(self):
self.Print(" </tr>") self.Print(" </tr>")
...@@ -356,7 +359,7 @@ table tr th :last-child, table tr td :last-child { ...@@ -356,7 +359,7 @@ table tr th :last-child, table tr td :last-child {
if run == None: if run == None:
self.PrintEmptyCell() self.PrintEmptyCell()
return return
self.Print(" <td>" + str(run.result()) + "</td>") self.Print(" <td>%3.1f</td>" % run.result())
def PrintComparison(self, run, main_run): def PrintComparison(self, run, main_run):
...@@ -371,7 +374,7 @@ table tr th :last-child, table tr td :last-child { ...@@ -371,7 +374,7 @@ table tr th :last-child, table tr td :last-child {
res = self.green(res) res = self.green(res)
elif diff.isNotablyNegative(): elif diff.isNotablyNegative():
res = self.red(res) res = self.red(res)
self.Print(" <td>" + res + "</td>") self.Print(" <td>%s</td>" % res)
def PrintEmptyCell(self): def PrintEmptyCell(self):
...@@ -379,7 +382,7 @@ table tr th :last-child, table tr td :last-child { ...@@ -379,7 +382,7 @@ table tr th :last-child, table tr td :last-child {
def StartTOC(self, title): def StartTOC(self, title):
self.Print("<h1>" + title + "</h1>") self.Print("<h1>%s</h1>" % title)
self.Print("<ul>") self.Print("<ul>")
def FinishTOC(self): def FinishTOC(self):
...@@ -399,14 +402,17 @@ def Render(args): ...@@ -399,14 +402,17 @@ def Render(args):
benchmark_suites = {} benchmark_suites = {}
run_names = OrderedDict() run_names = OrderedDict()
for json_file in args.json_file: for json_file_list in args.json_file_list:
if len(json_file) == 1: run_name = json_file_list[0]
filename = json_file[0] if run_name.endswith(".json"):
run_name = os.path.splitext(filename)[0] # The first item in the list is also a file name
run_name = os.path.splitext(run_name)[0]
filenames = json_file_list
else: else:
run_name = json_file[0] filenames = json_file_list[1:]
filename = json_file[1]
for filename in filenames:
print ("Processing result set \"%s\", file: %s" % (run_name, filename))
with open(filename) as json_data: with open(filename) as json_data:
data = json.load(json_data) data = json.load(json_data)
...@@ -460,7 +466,7 @@ def Render(args): ...@@ -460,7 +466,7 @@ def Render(args):
renderer.PrintFooter() renderer.PrintFooter()
renderer.FlushOutput() renderer.FlushOutput()
def pair(arg): def CommaSeparatedList(arg):
return [x for x in arg.split(',')] return [x for x in arg.split(',')]
if __name__ == '__main__': if __name__ == '__main__':
...@@ -470,9 +476,9 @@ if __name__ == '__main__': ...@@ -470,9 +476,9 @@ if __name__ == '__main__':
help="Optional title of the web page") help="Optional title of the web page")
parser.add_argument("-o", "--output", dest="output", parser.add_argument("-o", "--output", dest="output",
help="Write html output to this file rather than stdout") help="Write html output to this file rather than stdout")
parser.add_argument("json_file", nargs="+", type=pair, parser.add_argument("json_file_list", nargs="+", type=CommaSeparatedList,
help="[column name,]./path-to/result.json - a comma-separated" + help="[column name,]./path-to/result.json - a comma-separated" +
" pair of optional column name and path to json file") " list of optional column name and paths to json files")
args = parser.parse_args() args = parser.parse_args()
Render(args) Render(args)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment