Skip to content

Commit 04f1cc2

Browse files
committed
Support changing the LHS/RHS terms in performance comparisons
1 parent 7084909 commit 04f1cc2

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

reframe/frontend/cli.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,14 @@ def main():
702702
help='The delimiter to use when using `--table-format=csv`',
703703
envvar='RFM_TABLE_FORMAT_DELIM', configvar='general/table_format_delim'
704704
)
705+
misc_options.add_argument(
706+
'--term-lhs', action='store',
707+
help='LHS term in performance comparisons'
708+
)
709+
misc_options.add_argument(
710+
'--term-rhs', action='store',
711+
help='RHS term in performance comparisons'
712+
)
705713
misc_options.add_argument(
706714
'-v', '--verbose', action='count',
707715
help='Increase verbosity level of output',
@@ -1168,8 +1176,10 @@ def restrict_logging():
11681176
sys.exit(1)
11691177

11701178
printer.table(
1171-
reporting.performance_compare(options.performance_compare,
1172-
None, namepatt, *filt)
1179+
reporting.performance_compare(
1180+
options.performance_compare, None, namepatt, *filt,
1181+
options.term_lhs, options.term_rhs
1182+
)
11731183
)
11741184
sys.exit(0)
11751185

@@ -1769,7 +1779,9 @@ def module_unuse(*paths):
17691779
try:
17701780
if rt.get_option('storage/0/enable'):
17711781
data = reporting.performance_compare(
1772-
rt.get_option('general/0/perf_report_spec'), report
1782+
rt.get_option('general/0/perf_report_spec'), report,
1783+
term_lhs=options.term_lhs,
1784+
term_rhs=options.term_rhs
17731785
)
17741786
else:
17751787
data = report.report_data()

reframe/frontend/reporting/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,10 +690,11 @@ def compare_testcase_data(base_testcases, target_testcases, query):
690690

691691
@time_function
692692
def performance_compare(cmp, report=None, namepatt=None,
693-
filterA=None, filterB=None):
693+
filterA=None, filterB=None,
694+
term_lhs=None, term_rhs=None):
694695
with reraise_as(ReframeError, (ValueError,),
695696
'could not parse comparison spec'):
696-
query = parse_cmp_spec(cmp)
697+
query = parse_cmp_spec(cmp, term_lhs, term_rhs)
697698

698699
backend = StorageBackend.default()
699700
if query.lhs is None:

reframe/frontend/reporting/utility.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,16 @@ def __init__(self,
284284
rhs: QuerySelectorTestcase,
285285
aggregation: Aggregation,
286286
groups: List[str],
287-
columns: List[str]):
287+
columns: List[str],
288+
term_lhs: str, term_rhs: str):
288289
self.__lhs: QuerySelectorTestcase = lhs
289290
self.__rhs: QuerySelectorTestcase = rhs
290291
self.__aggregation: Aggregation = aggregation
291292
self.__tc_group_by: List[str] = groups
292293
self.__tc_attrs: List[str] = []
293294
self.__col_variants: Dict[str, List[str]] = {}
295+
self.__lhs_term: str = term_lhs or 'lhs'
296+
self.__rhs_term: str = term_rhs or 'rhs'
294297

295298
if self.is_compare() and 'pval' not in columns:
296299
# Always add `pval` if the query is a performance comparison
@@ -339,7 +342,7 @@ def is_compare(self):
339342
@property
340343
def lhs_column_suffix(self):
341344
'''The suffix of the lhs column in a comparison'''
342-
return ' (lhs)'
345+
return f' ({self.__lhs_term})'
343346

344347
@property
345348
def lhs_select_suffix(self):
@@ -349,7 +352,7 @@ def lhs_select_suffix(self):
349352
@property
350353
def rhs_column_suffix(self):
351354
'''The suffix of the rhs column in a comparison'''
352-
return ' (rhs)'
355+
return f' ({self.__rhs_term})'
353356

354357
@property
355358
def rhs_select_suffix(self):
@@ -405,7 +408,7 @@ def group_by(self) -> List[str]:
405408
DEFAULT_GROUP_BY = ['name', 'sysenv', 'pvar', 'punit']
406409

407410

408-
def parse_cmp_spec(spec):
411+
def parse_cmp_spec(spec, term_lhs=None, term_rhs=None):
409412
parts = spec.split('/')
410413
if len(parts) == 3:
411414
base_spec, target_spec, aggr, cols = None, *parts
@@ -420,4 +423,5 @@ def parse_cmp_spec(spec):
420423

421424
# Update base columns for listing
422425
columns = _parse_columns(cols, group_cols + aggr.attributes())
423-
return _QueryMatch(base, target, aggr, group_cols, columns)
426+
return _QueryMatch(base, target, aggr, group_cols, columns,
427+
term_lhs, term_rhs)

0 commit comments

Comments
 (0)