Skip to content

Commit dbf27cf

Browse files
authored
Merge pull request swiftlang#18709 from eeckstein/bm-scripts
2 parents 093f917 + edc7a0f commit dbf27cf

File tree

2 files changed

+41
-15
lines changed

2 files changed

+41
-15
lines changed

benchmark/scripts/bench_code_size.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ def main():
3030
argparser = argparse.ArgumentParser()
3131
argparser.add_argument(
3232
'-O', action='append_const', const='O', dest='opt_levels',
33-
help='test -O benchmarks')
33+
help='report code size of -O benchmarks')
3434
argparser.add_argument(
3535
'-Osize', action='append_const', const='Osize', dest='opt_levels',
36-
help='test -Osize benchmarks')
36+
help='report code size of -Osize benchmarks')
3737
argparser.add_argument(
3838
'-Onone', action='append_const', const='Onone', dest='opt_levels',
39-
help='test -Onone benchmarks')
39+
help='report code size of -Onone benchmarks')
40+
argparser.add_argument(
41+
'-swiftlibs', action='append_const', const='swiftlibs',
42+
dest='opt_levels',
43+
help='report code size of swift dylibs')
4044
argparser.add_argument(
4145
'oldbuilddir', nargs=1, type=str,
4246
help='old benchmark build directory')
@@ -62,10 +66,13 @@ def log_filename(bench_dir):
6266
old_logf = open(log_filename(old_dir), 'w')
6367
new_logf = open(log_filename(new_dir), 'w')
6468

65-
files = glob.glob(os.path.join(old_dir, opt_level + '-*' + platform + '*',
66-
'*.o'))
67-
files += glob.glob(os.path.join(old_dir, 'lib', 'swift', platform,
68-
'*.dylib'))
69+
if opt_level == 'swiftlibs':
70+
files = glob.glob(os.path.join(old_dir, 'lib', 'swift', platform,
71+
'*.dylib'))
72+
else:
73+
files = glob.glob(os.path.join(old_dir,
74+
opt_level + '-*' + platform + '*',
75+
'*.o'))
6976

7077
idx = 1
7178
for oldfile in files:

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)