Skip to content

Commit 516c99e

Browse files
author
y-p
committed
VB: add regex filtering to test_perf.py
1 parent 4c5461e commit 516c99e

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

vb_suite/test_perf.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@
3131
import argparse
3232
import tempfile
3333
import time
34+
import re
3435

3536
DEFAULT_MIN_DURATION = 0.01
36-
BASELINE_COMMIT = '2149c50' # 0.9.1 + regression fix + vb fixes # TODO: detect upstream/master
3737

3838
parser = argparse.ArgumentParser(description='Use vbench to generate a report comparing performance between two commits.')
3939
parser.add_argument('-a', '--auto',
4040
help='Execute a run using the defaults for the base and target commits.',
4141
action='store_true',
4242
default=False)
4343
parser.add_argument('-b', '--base-commit',
44-
help='The commit serving as performance baseline (default: %s).' % BASELINE_COMMIT,
44+
help='The commit serving as performance baseline ',
4545
type=str)
4646
parser.add_argument('-t', '--target-commit',
4747
help='The commit to compare against the baseline (default: HEAD).',
@@ -54,14 +54,18 @@
5454
metavar="<file>",
5555
dest='log_file',
5656
help='path of file in which to save the report (default: vb_suite.log).')
57-
57+
parser.add_argument('-r', '--regex',
58+
metavar="REGEX",
59+
dest='regex',
60+
default="",
61+
help='regex pat, only tests whose name matches the regext will be run.')
5862

5963
def get_results_df(db, rev):
6064
from pandas import DataFrame
6165
"""Takes a git commit hash and returns a Dataframe of benchmark results
6266
"""
6367
bench = DataFrame(db.get_benchmarks())
64-
results = DataFrame(db.get_rev_results(rev).values())
68+
results = DataFrame(map(list,db.get_rev_results(rev).values()))
6569

6670
# Sinch vbench.db._reg_rev_results returns an unlabeled dict,
6771
# we have to break encapsulation a bit.
@@ -80,9 +84,6 @@ def main():
8084
from vbench.db import BenchmarkDB
8185
from suite import REPO_PATH, BUILD, DB_PATH, PREPARE, dependencies, benchmarks
8286

83-
if not args.base_commit:
84-
args.base_commit = BASELINE_COMMIT
85-
8687
# GitRepo wants exactly 7 character hash?
8788
args.base_commit = args.base_commit[:7]
8889
if args.target_commit:
@@ -96,6 +97,8 @@ def main():
9697
prprint("TMP_DIR = %s" % TMP_DIR)
9798
prprint("LOG_FILE = %s\n" % args.log_file)
9899

100+
benchmarks = [x for x in benchmarks if re.search(args.regex,x.name)]
101+
99102
try:
100103
logfile = open(args.log_file, 'w')
101104

@@ -218,7 +221,7 @@ def _parse_commit_log(repo_path):
218221

219222
if __name__ == '__main__':
220223
args = parser.parse_args()
221-
if not args.auto and not args.base_commit and not args.target_commit:
224+
if not args.auto and (not args.base_commit and not args.target_commit):
222225
parser.print_help()
223226
else:
224227
main()

0 commit comments

Comments
 (0)