Skip to content

Commit e29f69e

Browse files
committed
benchmarks: combine everything which is needed into run_smoke_bench
Now, run_smoke_bench runs the benchmarks, compares performance and code size and reports the results - on stdout and as a markdown file. No need to run bench_code_size.py and compare_perf_tests.py separately. This has two benefits: - It's much easier to run it locally - It's now more transparent what's happening in '@SwiftCI benchmark', because now all the logic is in run_smoke_bench rather than in the not visible script on the CI bot. I also remove the branch-arguments from ReportFormatter in ompare_perf_tests.py. They were not used anyway. For a smooth rollout in CI, I created a new script rather than changing the existing one. Once everything is setup in CI, I'll delete the old run_smoke_test.py and bench_code_size.py.
1 parent 8bfcab3 commit e29f69e

File tree

3 files changed

+378
-32
lines changed

3 files changed

+378
-32
lines changed

benchmark/scripts/compare_perf_tests.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,10 @@ class ReportFormatter(object):
477477
GitHub), `git` and `html`.
478478
"""
479479

480-
def __init__(self, comparator, old_branch, new_branch, changes_only,
480+
def __init__(self, comparator, changes_only,
481481
single_table=False):
482482
"""Initialize with `TestComparator` and names of branches."""
483483
self.comparator = comparator
484-
self.old_branch = old_branch
485-
self.new_branch = new_branch
486484
self.changes_only = changes_only
487485
self.single_table = single_table
488486

@@ -600,7 +598,6 @@ def table(title, results, is_strong=False, is_open=False):
600598
])
601599

602600
return ''.join([
603-
# FIXME print self.old_branch, self.new_branch
604601
table('Regression', self.comparator.decreased, True, True),
605602
table('Improvement', self.comparator.increased, True),
606603
('' if self.changes_only else
@@ -675,7 +672,6 @@ def table(title, results, speedup_color):
675672

676673
return self.HTML.format(
677674
''.join([
678-
# FIXME print self.old_branch, self.new_branch
679675
table('Regression', self.comparator.decreased, 'red'),
680676
table('Improvement', self.comparator.increased, 'green'),
681677
('' if self.changes_only else
@@ -705,31 +701,33 @@ def parse_args(args):
705701
'--single-table',
706702
help='Combine data in a single table in git and markdown formats',
707703
action='store_true')
708-
parser.add_argument('--new-branch',
709-
help='Name of the new branch', default='NEW_MIN')
710-
parser.add_argument('--old-branch',
711-
help='Name of the old branch', default='OLD_MIN')
712704
parser.add_argument('--delta-threshold',
713705
help='Delta threshold. Default 0.05.',
714706
type=float, default=0.05)
715707
return parser.parse_args(args)
716708

717709

718-
def main():
719-
"""Compare benchmarks for changes in a formatted report."""
720-
args = parse_args(sys.argv[1:])
721-
comparator = TestComparator(LogParser.results_from_file(args.old_file),
722-
LogParser.results_from_file(args.new_file),
723-
args.delta_threshold)
724-
formatter = ReportFormatter(comparator, args.old_branch, args.new_branch,
725-
args.changes_only, args.single_table)
710+
def create_report(old_results, new_results, delta_threshold, format,
711+
changes_only=True, single_table=True):
712+
comparator = TestComparator(old_results, new_results, delta_threshold)
713+
formatter = ReportFormatter(comparator, changes_only, single_table)
726714
formats = {
727715
'markdown': formatter.markdown,
728716
'git': formatter.git,
729717
'html': formatter.html
730718
}
731719

732-
report = formats[args.format]()
720+
report = formats[format]()
721+
return report
722+
723+
724+
def main():
725+
"""Compare benchmarks for changes in a formatted report."""
726+
args = parse_args(sys.argv[1:])
727+
report = create_report(LogParser.results_from_file(args.old_file),
728+
LogParser.results_from_file(args.new_file),
729+
args.delta_threshold, args.format,
730+
args.changes_only, args.single_table)
733731
print(report)
734732

735733
if args.output:

0 commit comments

Comments
 (0)