Skip to content

Make loops.json files per-runner-configurable #394

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 5 commits into from
Apr 7, 2025
Merged
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
12 changes: 11 additions & 1 deletion bench_runner/scripts/run_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
)
# Environment variables that control the execution of CPython
ENV_VARS = ["PYTHON_JIT", "PYPERF_PERF_RECORD_EXTRA_OPTS"]
LOOPS_FILE_ENV_VAR = "PYPERFORMANCE_LOOPS_FILE"


class NoBenchmarkError(Exception):
Expand Down Expand Up @@ -82,6 +83,10 @@ def run_benchmarks(
if extra_args is None:
extra_args = []

if loops_file := os.environ.get(LOOPS_FILE_ENV_VAR):
extra_args.append("--same-loops")
extra_args.append(loops_file)

if affinity := os.environ.get("CPU_AFFINITY"):
extra_args.append(f"--affinity={affinity}")

Expand Down Expand Up @@ -133,7 +138,12 @@ def collect_pystats(

all_benchmarks = get_benchmark_names(benchmarks)

extra_args = ["--same-loops", "loops.json", "--hook", "pystats"]
# Default to loops.json if not explicitly set, like before the
# environment variable was added.
if LOOPS_FILE_ENV_VAR not in os.environ:
os.environ[LOOPS_FILE_ENV_VAR] = "loops.json"

extra_args = ["--hook", "pystats"]

if flags is None:
flags = []
Expand Down