Skip to content

Commit edc7a0f

Browse files
committed
benchmarks: add an option to the compare_perf_tests script to output improvements and regressions in an single table.
Instead of separate tables. Only affects git and markdown output.
1 parent b4a61d7 commit edc7a0f

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

benchmark/scripts/compare_perf_tests.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,13 @@ class ReportFormatter(object):
220220
`values()` into report table. Supported formats are: `markdown` (used for
221221
displaying benchmark results on GitHub), `git` and `html`.
222222
"""
223-
def __init__(self, comparator, old_branch, new_branch, changes_only):
223+
def __init__(self, comparator, old_branch, new_branch, changes_only,
224+
single_table=False):
224225
self.comparator = comparator
225226
self.old_branch = old_branch
226227
self.new_branch = new_branch
227228
self.changes_only = changes_only
229+
self.single_table = single_table
228230

229231
MARKDOWN_DETAIL = """
230232
<details {3}>
@@ -266,6 +268,7 @@ def max_widths(maximum, widths):
266268

267269
def _formatted_text(self, ROW, HEADER_SEPARATOR, DETAIL):
268270
widths = self._column_widths()
271+
self.header_printed = False
269272

270273
def justify_columns(contents):
271274
return tuple([c.ljust(w) for w, c in zip(widths, contents)])
@@ -285,12 +288,24 @@ def table(title, results, is_strong=False, is_open=False):
285288
row(format_columns(result_comparison.values(), is_strong))
286289
for result_comparison in results
287290
]
288-
return ('' if not rows else
289-
DETAIL.format(*[
290-
title, len(results),
291-
(header(results[0].header) + ''.join(rows)),
292-
('open' if is_open else '')
293-
]))
291+
if not rows:
292+
return ''
293+
294+
if self.single_table:
295+
t = ''
296+
if not self.header_printed:
297+
t += header(results[0].header)
298+
self.header_printed = True
299+
t += row(('**' + title + '**', '', '', '', ''))
300+
t += ''.join(rows)
301+
return t
302+
303+
return DETAIL.format(
304+
*[
305+
title, len(results),
306+
(header(results[0].header) + ''.join(rows)),
307+
('open' if is_open else '')
308+
])
294309

295310
return ''.join([
296311
# FIXME print self.old_branch, self.new_branch
@@ -393,6 +408,10 @@ def parse_args(args):
393408
parser.add_argument('--output', help='Output file name')
394409
parser.add_argument('--changes-only',
395410
help='Output only affected tests', action='store_true')
411+
parser.add_argument(
412+
'--single-table',
413+
help='Combine data in a single table in git and markdown formats',
414+
action='store_true')
396415
parser.add_argument('--new-branch',
397416
help='Name of the new branch', default='NEW_MIN')
398417
parser.add_argument('--old-branch',
@@ -408,7 +427,7 @@ def main():
408427
comparator = TestComparator(args.old_file, args.new_file,
409428
args.delta_threshold)
410429
formatter = ReportFormatter(comparator, args.old_branch, args.new_branch,
411-
args.changes_only)
430+
args.changes_only, args.single_table)
412431
formats = {
413432
'markdown': formatter.markdown,
414433
'git': formatter.git,

0 commit comments

Comments
 (0)