Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
11 changes: 9 additions & 2 deletions src/pytest_codspeed/instruments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,24 @@ 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 (
ValgrindInstrument,
)
from pytest_codspeed.instruments.walltime import WallTimeInstrument

if mode == MeasurementMode.Instrumentation:
if mode == MeasurementMode.Simulation:
return ValgrindInstrument
else:
return WallTimeInstrument
2 changes: 1 addition & 1 deletion src/pytest_codspeed/instruments/hooks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion src/pytest_codspeed/instruments/valgrind.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_codspeed/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/test_pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"]
)


Expand Down
10 changes: 4 additions & 6 deletions tests/test_pytest_plugin_cpu_instrumentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"]
)


Expand All @@ -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(
[
(
Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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)
Loading