Skip to content

Commit ccc8791

Browse files
committed
[leaks-checker] Add support for filtering tests and changing the number of samples/iters run. This will make it easy to bisect using the Benchmark_LeaksRunner script.
1 parent 91f106e commit ccc8791

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

benchmark/scripts/Benchmark_RuntimeLeaksRunner.in

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,30 @@ class LeaksRunnerResult(perf_test_driver.Result):
7676

7777
class LeaksRunnerBenchmarkDriver(perf_test_driver.BenchmarkDriver):
7878

79-
def __init__(self, binary, xfail_list):
79+
def __init__(self, binary, xfail_list, num_samples, num_iters):
8080
perf_test_driver.BenchmarkDriver.__init__(
8181
self, binary, xfail_list,
8282
enable_parallel=True)
83+
self.num_samples = num_samples
84+
self.num_iters = num_iters
8385

8486
def print_data_header(self, max_test_len):
8587
fmt = '{:<%d}{:<10}{:}' % (max_test_len + 5)
8688
print(fmt.format('Name', 'Result', 'RC Delta'))
8789

90+
# Propagate any data from this class that is needed for individual
91+
# tests. The reason this is needed is to avoid issues with attempting to
92+
# access a value in a different process.
8893
def prepare_input(self, name):
89-
return {}
94+
return {'num_samples': self.num_samples, 'num_iters': self.num_iters}
9095

9196
def process_input(self, data):
9297
test_name = '({},{})'.format(data['opt'], data['test_name'])
9398
print("Running {}...".format(test_name))
9499
sys.stdout.flush()
95100
try:
96-
p = subprocess.Popen([data['path'], "--run-all", "--num-samples=2",
97-
"--num-iters={}".format(2), data['test_name']],
101+
p = subprocess.Popen([data['path'], "--run-all", "--num-samples={}".format(data['num_samples']),
102+
"--num-iters={}".format(data['num_iters']), data['test_name']],
98103
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
99104
error_out = p.communicate()[1].split("\n")
100105
except OSError:
@@ -121,9 +126,19 @@ class LeaksRunnerBenchmarkDriver(perf_test_driver.BenchmarkDriver):
121126

122127
SWIFT_BIN_DIR = os.path.dirname(os.path.abspath(__file__))
123128

129+
def parse_args():
130+
import argparse
131+
parser = argparse.ArgumentParser()
132+
parser.add_argument('-filter', type=str, default=None,
133+
help='Filter out any test that does not match the given regex')
134+
parser.add_argument('-num-samples', type=int, default=2)
135+
parser.add_argument('-num-iters', type=int, default=2)
136+
return parser.parse_args()
137+
124138
if __name__ == "__main__":
125-
l = LeaksRunnerBenchmarkDriver(SWIFT_BIN_DIR, XFAIL_LIST)
126-
if l.run():
139+
args = parse_args()
140+
l = LeaksRunnerBenchmarkDriver(SWIFT_BIN_DIR, XFAIL_LIST, args.num_samples, args.num_iters)
141+
if l.run(args.filter):
127142
sys.exit(0)
128143
else:
129144
sys.exit(-1)

0 commit comments

Comments
 (0)