Skip to content
Open
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
23 changes: 18 additions & 5 deletions bench/scripts/run_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,19 @@ def find_default_build_dir():
# Per-profile orchestration.
# ---------------------------------------------------------------------------

def run_profile(name, profile, build_dir, out_dir, extra_args):
def run_profile(name, profile, build_dir, out_dir, extra_args, dry_run):
exe = _resolve_exe(build_dir, profile["exe_stems"])

if exe is None:
print(f"[{name}] could not find any of {profile['exe_stems']} under {build_dir}/bench/",
file=sys.stderr)
return False
if not dry_run:
print(
f"[{name}] could not find any of {profile['exe_stems']} "
f"under {build_dir}/bench/",
file=sys.stderr,
)
return False

exe = build_dir / "bench" / profile["exe_stems"][0]
json_path = out_dir / f"{name}.json"
md_path = out_dir / f"{name}.md"
csv_path = out_dir / f"{name}.csv"
Expand All @@ -395,6 +401,8 @@ def run_profile(name, profile, build_dir, out_dir, extra_args):
cmd += extra_args
timeout = profile.get("timeout_seconds", DEFAULT_TIMEOUT_SECONDS)
print(f"[{name}] {' '.join(cmd)} (timeout {timeout}s)")
if dry_run:
return True
Comment on lines +404 to +405

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Dry-run output loses argument boundaries

Dry runs render paths and forwarded NVBench arguments with ' '.join(cmd), so whitespace and shell metacharacters are not quoted. The displayed text therefore does not faithfully represent the command and cannot be reliably copied or interpreted when an argument contains those characters.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

try:
res = subprocess.run(cmd, timeout=timeout)
except subprocess.TimeoutExpired:
Expand Down Expand Up @@ -433,6 +441,11 @@ def main():
"--out-dir", type=Path, default=Path("bench_results"),
help="Directory for nvbench JSON/MD/CSV output (default: ./bench_results).",
)
parser.add_argument(
"--dry-run",
action="store_true",
help="Print benchmark commands without executing them.",
)
parser.add_argument(
"nvbench_args", nargs=argparse.REMAINDER,
help="Extra args forwarded verbatim to the nvbench executable. "
Expand All @@ -447,7 +460,7 @@ def main():
profiles = sorted(PROFILES) if args.profile == "all" else [args.profile]
failures = 0
for name in profiles:
ok = run_profile(name, PROFILES[name], build_dir, args.out_dir, extra)
ok = run_profile(name, PROFILES[name], build_dir, args.out_dir, extra, args.dry_run,)
if not ok:
failures += 1

Expand Down