Skip to content

Commit eeccea6

Browse files
authored
Merge pull request #394 from Yhg1s/per-runner-loops
Make loops.json files per-runner-configurable
2 parents 09b911f + 18aec6e commit eeccea6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Diff for: bench_runner/scripts/run_benchmarks.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
)
3535
# Environment variables that control the execution of CPython
3636
ENV_VARS = ["PYTHON_JIT", "PYPERF_PERF_RECORD_EXTRA_OPTS"]
37+
LOOPS_FILE_ENV_VAR = "PYPERFORMANCE_LOOPS_FILE"
3738

3839

3940
class NoBenchmarkError(Exception):
@@ -82,6 +83,10 @@ def run_benchmarks(
8283
if extra_args is None:
8384
extra_args = []
8485

86+
if loops_file := os.environ.get(LOOPS_FILE_ENV_VAR):
87+
extra_args.append("--same-loops")
88+
extra_args.append(loops_file)
89+
8590
if affinity := os.environ.get("CPU_AFFINITY"):
8691
extra_args.append(f"--affinity={affinity}")
8792

@@ -133,7 +138,12 @@ def collect_pystats(
133138

134139
all_benchmarks = get_benchmark_names(benchmarks)
135140

136-
extra_args = ["--same-loops", "loops.json", "--hook", "pystats"]
141+
# Default to loops.json if not explicitly set, like before the
142+
# environment variable was added.
143+
if LOOPS_FILE_ENV_VAR not in os.environ:
144+
os.environ[LOOPS_FILE_ENV_VAR] = "loops.json"
145+
146+
extra_args = ["--hook", "pystats"]
137147

138148
if flags is None:
139149
flags = []

0 commit comments

Comments
 (0)