diff --git a/README.md b/README.md index aa1a909..161763a 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ jobs: - name: Run benchmarks uses: CodSpeedHQ/action@v4 with: - mode: instrumentation # or `walltime` + mode: simulation # or `walltime` token: ${{ secrets.CODSPEED_TOKEN }} run: pytest tests/ --codspeed ``` diff --git a/pyproject.toml b/pyproject.toml index 0ab2879..a97fcb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,6 +45,8 @@ compat = [ ] [tool.uv] +# Python builds change with uv versions, and we are quite susceptible to that. +# We pin uv to to make sure reproducibility is maintained for any contributor. required-version = "0.9.5" [tool.uv.sources] diff --git a/src/pytest_codspeed/instruments/__init__.py b/src/pytest_codspeed/instruments/__init__.py index 71936db..08dace3 100644 --- a/src/pytest_codspeed/instruments/__init__.py +++ b/src/pytest_codspeed/instruments/__init__.py @@ -56,9 +56,16 @@ def get_result_dict( class MeasurementMode(str, Enum): - Instrumentation = "instrumentation" + Simulation = "simulation" WallTime = "walltime" + @classmethod + def _missing_(cls, value: object): + # Accept "instrumentation" as deprecated alias for "simulation" + if value == "instrumentation": + return cls.Simulation + return None + def get_instrument_from_mode(mode: MeasurementMode) -> type[Instrument]: from pytest_codspeed.instruments.valgrind import ( @@ -66,7 +73,7 @@ def get_instrument_from_mode(mode: MeasurementMode) -> type[Instrument]: ) from pytest_codspeed.instruments.walltime import WallTimeInstrument - if mode == MeasurementMode.Instrumentation: + if mode == MeasurementMode.Simulation: return ValgrindInstrument else: return WallTimeInstrument diff --git a/src/pytest_codspeed/instruments/hooks/__init__.py b/src/pytest_codspeed/instruments/hooks/__init__.py index 19aea91..3a852d6 100644 --- a/src/pytest_codspeed/instruments/hooks/__init__.py +++ b/src/pytest_codspeed/instruments/hooks/__init__.py @@ -78,5 +78,5 @@ def set_integration(self, name: str, version: str) -> None: warnings.warn("Failed to set integration name and version", RuntimeWarning) def is_instrumented(self) -> bool: - """Check if instrumentation is active.""" + """Check if simulation is active.""" return self.lib.instrument_hooks_is_instrumented(self.instance) diff --git a/src/pytest_codspeed/instruments/valgrind.py b/src/pytest_codspeed/instruments/valgrind.py index f604d1f..b6667f8 100644 --- a/src/pytest_codspeed/instruments/valgrind.py +++ b/src/pytest_codspeed/instruments/valgrind.py @@ -39,7 +39,7 @@ def __init__(self, config: CodSpeedConfig) -> None: def get_instrument_config_str_and_warns(self) -> tuple[str, list[str]]: config = ( - f"mode: instrumentation, " + f"mode: simulation, " f"callgraph: {'enabled' if SUPPORTS_PERF_TRAMPOLINE else 'not supported'}" ) warnings = [] diff --git a/src/pytest_codspeed/plugin.py b/src/pytest_codspeed/plugin.py index 26a0ca1..0d2853b 100644 --- a/src/pytest_codspeed/plugin.py +++ b/src/pytest_codspeed/plugin.py @@ -115,7 +115,7 @@ def pytest_configure(config: pytest.Config): if os.environ.get("CODSPEED_RUNNER_MODE") == "walltime": default_mode = MeasurementMode.WallTime.value else: - default_mode = MeasurementMode.Instrumentation.value + default_mode = MeasurementMode.Simulation.value else: default_mode = MeasurementMode.WallTime.value diff --git a/tests/test_pytest_plugin.py b/tests/test_pytest_plugin.py index 89cd7b1..452e9da 100644 --- a/tests/test_pytest_plugin.py +++ b/tests/test_pytest_plugin.py @@ -34,7 +34,7 @@ def test_bench_enabled_header_without_perf( with codspeed_env(): result = pytester.runpytest() result.stdout.fnmatch_lines( - ["codspeed: * (enabled, mode: instrumentation, callgraph: not supported)"] + ["codspeed: * (enabled, mode: simulation, callgraph: not supported)"] ) diff --git a/tests/test_pytest_plugin_cpu_instrumentation.py b/tests/test_pytest_plugin_cpu_instrumentation.py index 4856ae6..ee0eca8 100644 --- a/tests/test_pytest_plugin_cpu_instrumentation.py +++ b/tests/test_pytest_plugin_cpu_instrumentation.py @@ -21,7 +21,7 @@ def test_bench_enabled_header_with_perf( with codspeed_env(): result = pytester.runpytest() result.stdout.fnmatch_lines( - ["codspeed: * (enabled, mode: instrumentation, callgraph: enabled)"] + ["codspeed: * (enabled, mode: simulation, callgraph: enabled)"] ) @@ -36,7 +36,7 @@ def _(): return 1 + 1 """ ) - result = run_pytest_codspeed_with_mode(pytester, MeasurementMode.Instrumentation) + result = run_pytest_codspeed_with_mode(pytester, MeasurementMode.Simulation) result.stdout.fnmatch_lines( [ ( @@ -132,7 +132,7 @@ def foo(): benchmark.pedantic(foo, rounds=10, iterations=100) """ ) - result = run_pytest_codspeed_with_mode(pytester, MeasurementMode.Instrumentation) + result = run_pytest_codspeed_with_mode(pytester, MeasurementMode.Simulation) result.stdout.fnmatch_lines( [ "*UserWarning: Valgrind instrument ignores rounds and iterations settings " @@ -192,8 +192,6 @@ def target(a, b, c): """ ) with codspeed_env(): - result = run_pytest_codspeed_with_mode( - pytester, MeasurementMode.Instrumentation - ) + result = run_pytest_codspeed_with_mode(pytester, MeasurementMode.Simulation) assert result.ret == 0, "the run should have succeeded" result.assert_outcomes(passed=1)