Files
1ndahous3 0f7c1843a4 Fix benchmark execution and library dependency reports (#9264)
* Fix benchmark execution and library dependency reports

Assisted-by: Codex:GPT-6

* Clarify relative benchmark interpreter paths

Assisted-by: Codex:GPT-6
2026-10-21 11:58:17 +09:00

37 lines
959 B
Python

import os
import subprocess
import sys
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parent.parent
BENCHES = ROOT / "benches"
# Interpreters:
default_rustpython = (
ROOT
/ "target"
/ "release"
/ ("rustpython.exe" if os.name == "nt" else "rustpython")
)
rustpython_exe = str(Path(os.environ.get("RUSTPYTHON", default_rustpython)).resolve())
cpython_exe = sys.executable
pythons = [cpython_exe, rustpython_exe]
# Benchmark scripts:
benchmarks = [
BENCHES / "benchmarks" / "nbody.py",
BENCHES / "benchmarks" / "mandelbrot.py",
BENCHES / "microbenchmarks" / "strings.py",
]
exe_ids = ["cpython", "rustpython"]
benchmark_ids = [benchmark.name for benchmark in benchmarks]
@pytest.mark.parametrize("exe", pythons, ids=exe_ids)
@pytest.mark.parametrize("script", benchmarks, ids=benchmark_ids)
def test_bench(exe, script, benchmark):
benchmark(subprocess.run, [exe, str(script)], cwd=ROOT, check=True)