Skip to content

[feat] Support discrete testcase filters when comparing performance #3438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/manpage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,16 @@ Result storage commands

The ``CMPSPEC`` argument specifies how testcases will be selected, aggregated and presented.
This option can be combined with :option:`--name` and :option:`--filter-expr` to restrict the listed tests.
The :option:`--filter-expr` option specifically can be specified twice, in which case the first expression will be used the to filter the first set of test cases, and the second one will filter the second set.

Check the :ref:`querying-past-results` section for the exact syntax of ``CMPSPEC``.

.. versionadded:: 4.7

.. versionchanged:: 4.8

The :option:`--filter-expr` can now be passed twice with :option:`--performance-compare`.

Other commands
^^^^^^^^^^^^^^

Expand Down
28 changes: 19 additions & 9 deletions reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def main():
help='Exclude checks whose name matches PATTERN'
)
select_options.add_argument(
'-E', '--filter-expr', action='store', metavar='EXPR',
'-E', '--filter-expr', action='append', metavar='EXPR',
help='Select checks that satisfy the expression EXPR'
)

Expand Down Expand Up @@ -1031,8 +1031,9 @@ def restrict_logging():
namepatt = '|'.join(options.names)
with exit_gracefully_on_error('failed to retrieve test case data',
printer):
filt = options.filter_expr[-1] if options.filter_expr else None
printer.table(reporting.testcase_data(
options.list_stored_testcases, namepatt, options.filter_expr
options.list_stored_testcases, namepatt, filt
))
sys.exit(0)

Expand All @@ -1052,9 +1053,9 @@ def restrict_logging():
namepatt = '|'.join(options.names)
with exit_gracefully_on_error('failed to retrieve test case data',
printer):
filt = options.filter_expr[-1] if options.filter_expr else None
printer.info(jsonext.dumps(reporting.testcase_info(
options.describe_stored_testcases,
namepatt, options.filter_expr
options.describe_stored_testcases, namepatt, filt
), indent=2))
sys.exit(0)

Expand All @@ -1070,11 +1071,20 @@ def restrict_logging():
namepatt = '|'.join(options.names)
with exit_gracefully_on_error('failed to generate performance report',
printer):
filt = [None, None]
if options.filter_expr is not None:
if len(options.filter_expr) == 1:
filt[0] = options.filter_expr[0]
elif len(options.filter_expr) == 2:
filt[:] = options.filter_expr
else:
printer.error('cannot apply `-E` option more than twice '
'in performance comparisons')
sys.exit(1)

printer.table(
reporting.performance_compare(options.performance_compare,
None,
namepatt,
options.filter_expr)
None, namepatt, *filt)
)
sys.exit(0)

Expand Down Expand Up @@ -1292,12 +1302,12 @@ def print_infoline(param, value):
)

if options.filter_expr:
testcases = filter(filters.validates(options.filter_expr),
testcases = filter(filters.validates(options.filter_expr[-1]),
testcases)

testcases = list(testcases)
printer.verbose(
f'Filtering test cases(s) by {options.filter_expr}: '
f'Filtering test cases(s) by {options.filter_expr[-1]}: '
f'{len(testcases)} remaining'
)

Expand Down
7 changes: 4 additions & 3 deletions reframe/frontend/reporting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,8 @@ def compare_testcase_data(base_testcases, target_testcases, base_fn, target_fn,


@time_function
def performance_compare(cmp, report=None, namepatt=None, test_filter=None):
def performance_compare(cmp, report=None, namepatt=None,
filterA=None, filterB=None):
with reraise_as(ReframeError, (ValueError,),
'could not parse comparison spec'):
match = parse_cmp_spec(cmp)
Expand All @@ -786,9 +787,9 @@ def performance_compare(cmp, report=None, namepatt=None, test_filter=None):
except IndexError:
tcs_base = []
else:
tcs_base = backend.fetch_testcases(match.base, namepatt, test_filter)
tcs_base = backend.fetch_testcases(match.base, namepatt, filterA)

tcs_target = backend.fetch_testcases(match.target, namepatt, test_filter)
tcs_target = backend.fetch_testcases(match.target, namepatt, filterB)
return compare_testcase_data(tcs_base, tcs_target, match.aggregator,
match.aggregator, match.groups, match.columns)

Expand Down
Loading