Skip to content

Commit a05b35c

Browse files
authored
Merge pull request #9026 from palimondo/SR-4598
[benchmark] Support multiple regular expression filters in Benchmark_Driver
2 parents b3da892 + 2f8f118 commit a05b35c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

benchmark/scripts/Benchmark_Driver

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ def instrument_test(driver_path, test, num_samples):
121121
def get_tests(driver_path, args):
122122
"""Return a list of available performance tests"""
123123
tests = subprocess.check_output([driver_path, '--list']).split()[2:]
124-
if args.filter:
125-
return filter(lambda name: name.startswith(args.filter), tests)
124+
if args.filters:
125+
regexes = [re.compile(pattern) for pattern in args.filters]
126+
return sorted(list(set([name for pattern in regexes
127+
for name in tests if pattern.match(name)])))
126128
if not args.benchmarks:
127129
return tests
128130
return sorted(list(set(tests).intersection(set(args.benchmarks))))
@@ -362,7 +364,7 @@ def positive_int(value):
362364

363365
def main():
364366
parser = argparse.ArgumentParser(
365-
epilog='Example: ./Benchmark_Driver run -i 5 -f Array'
367+
epilog='Example: ./Benchmark_Driver run -i 5 -f Prefix -f .*Suffix.*'
366368
)
367369
subparsers = parser.add_subparsers(
368370
title='Swift benchmark driver commands',
@@ -375,8 +377,9 @@ def main():
375377
default=[],
376378
help='benchmark to run (default: all)', nargs='*', metavar="BENCHMARK")
377379
benchmarks_group.add_argument(
378-
'-f', '--filter',
379-
help='run all tests whose name starts with PREFIX', metavar="PREFIX")
380+
'-f', '--filter', dest='filters', action='append',
381+
help='run all tests whose name match regular expression PATTERN, ' +
382+
'multiple filters are supported', metavar="PATTERN")
380383
parent_parser.add_argument(
381384
'-t', '--tests',
382385
help='directory containing Benchmark_O{,none,unchecked} ' +

0 commit comments

Comments
 (0)