Skip to content

Commit 0dcbfeb

Browse files
committed
Add support for passing --same-loops to pyperformance for regular runs (not
just pystats) by setting the PYPERFORMANCE_LOOPS_FILE environment variable.
1 parent 0dee4d0 commit 0dcbfeb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

bench_runner/scripts/run_benchmarks.py

Lines changed: 11 additions & 1 deletion
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
args = [
8691
sys.executable,
8792
"-m",
@@ -130,7 +135,12 @@ def collect_pystats(
130135

131136
all_benchmarks = get_benchmark_names(benchmarks)
132137

133-
extra_args = ["--same-loops", "loops.json", "--hook", "pystats"]
138+
# Default to loops.json if not explicitly set, like before the
139+
# environment variable was added.
140+
if LOOPS_FILE_ENV_VAR not in os.environ:
141+
os.environ[LOOPS_FILE_ENV_VAR] = "loops.json"
142+
143+
extra_args = ["--hook", "pystats"]
134144

135145
if flags is None:
136146
flags = []

0 commit comments

Comments
 (0)