Clarify nvbench-compare validation helpers and CLI help

Factor finite-value checks through a common helper so positive and
non-negative finite predicates share the same None/finite guard. Add a
comment explaining the positive lower-bound clamp used for mean/stdev
intervals, since later ratio and log-distance checks require positive
bounds.

Also quote the --axis pow2 example in CLI help so shell users can copy
the example safely.
This commit is contained in:
Oleksandr Pavlyk
2026-06-29 16:11:56 -05:00
parent 6740e59722
commit 92a07c53e2

View File

@@ -1240,12 +1240,16 @@ def compute_relative_dispersion(dispersion, center):
return dispersion / center
def is_finite(value):
return value is not None and math.isfinite(value)
def is_positive_finite(value):
return value is not None and value > 0.0 and math.isfinite(value)
return is_finite(value) and value > 0.0
def is_nonnegative_finite(value):
return value is not None and math.isfinite(value) and value >= 0.0
return is_finite(value) and value >= 0.0
def derive_absolute_dispersion(relative_dispersion, center):
@@ -1305,6 +1309,7 @@ def compute_mean_summary_interval(timing):
if not is_positive_finite(timing.mean) or not is_nonnegative_finite(timing.stdev):
return None
# Keep the lower bound positive so later ratio/log-distance checks are defined.
lower = max(timing.mean - timing.stdev, timing.mean * 0.001)
upper = timing.mean + timing.stdev
if is_positive_finite(timing.minimum):
@@ -3332,7 +3337,7 @@ def main() -> int:
dest="filter_actions",
action=OrderedBenchmarkFilterAction,
help=(
"Filter on axis value, e.g. -a Elements{io}[pow2]=20. Applies to the "
"Filter on axis value, e.g. -a 'Elements{io}[pow2]=20'. Applies to the "
"most recent --benchmark, or all benchmarks if specified before any "
"--benchmark arguments."
),