Skip to content

Commit eef71d4

Browse files
committed
[benchmark] Check added benchmarks
Script for integrating BenchmarkDoctor’s check of newly added benchmarks into CI workflow.
1 parent c71d863 commit eef71d4

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
# ===--- check_added_bench -----------------------------------------------===//
5+
#
6+
# This source file is part of the Swift.org open source project
7+
#
8+
# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
9+
# Licensed under Apache License v2.0 with Runtime Library Exception
10+
#
11+
# See https://swift.org/LICENSE.txt for license information
12+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
13+
#
14+
# ===---------------------------------------------------------------------===//
15+
#
16+
# Runs BenchmarkDoctor's check on newly added benchmarks.
17+
#
18+
# ===---------------------------------------------------------------------===//
19+
20+
from __future__ import print_function
21+
22+
import argparse
23+
import os
24+
25+
from imp import load_source
26+
# import Benchmark_Driver # doesn't work because it misses '.py' extension
27+
Benchmark_Driver = load_source(
28+
'Benchmark_Driver', os.path.join(os.path.dirname(
29+
os.path.abspath(__file__)), 'Benchmark_Driver'))
30+
# from Benchmark_Driver import BenchmarkDriver, BenchmarkDoctor
31+
BenchmarkDriver = Benchmark_Driver.BenchmarkDriver
32+
BenchmarkDoctor = Benchmark_Driver.BenchmarkDoctor
33+
34+
class Args(object):
35+
def __init__(self, tests):
36+
self.benchmarks = None
37+
self.filters = None
38+
self.tests = os.path.join(tests, 'bin')
39+
self.optimization = 'O'
40+
41+
def main():
42+
argparser = argparse.ArgumentParser()
43+
argparser.add_argument(
44+
'oldbuilddir', nargs=1, type=str, help='old benchmark build directory')
45+
argparser.add_argument(
46+
'newbuilddir', nargs=1, type=str, help='new benchmark build directory')
47+
argparser.add_argument(
48+
'-v', '--verbose', action='store_true',
49+
help='show more details during benchmark analysis')
50+
args = argparser.parse_args()
51+
52+
old = BenchmarkDriver(Args(args.oldbuilddir[0]))
53+
new = BenchmarkDriver(Args(args.newbuilddir[0]))
54+
added = set(new.tests).difference(set(old.tests))
55+
new.tests = list(added)
56+
doctor = BenchmarkDoctor(args, driver=new)
57+
doctor.check()
58+
return 0
59+
60+
61+
if __name__ == '__main__':
62+
exit(main())

0 commit comments

Comments
 (0)