Skip to content

Commit adee8a1

Browse files
feat: rename instrumentation to simulation
`instrumentation` is still accepted as an input, but it maps to simulation internally, as we plan to phase it out. Signed-off-by: Guillaume Lagrange <[email protected]>
1 parent 08e0519 commit adee8a1

File tree

7 files changed

+18
-13
lines changed

7 files changed

+18
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ jobs:
113113
- name: Run benchmarks
114114
uses: CodSpeedHQ/action@v4
115115
with:
116-
mode: instrumentation # or `walltime`
116+
mode: simulation # or `walltime`
117117
token: ${{ secrets.CODSPEED_TOKEN }}
118118
run: pytest tests/ --codspeed
119119
```

src/pytest_codspeed/instruments/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,24 @@ def get_result_dict(
5656

5757

5858
class MeasurementMode(str, Enum):
59-
Instrumentation = "instrumentation"
59+
Simulation = "simulation"
6060
WallTime = "walltime"
6161

62+
@classmethod
63+
def _missing_(cls, value: object):
64+
# Accept "instrumentation" as deprecated alias for "simulation"
65+
if value == "instrumentation":
66+
return cls.Simulation
67+
return None
68+
6269

6370
def get_instrument_from_mode(mode: MeasurementMode) -> type[Instrument]:
6471
from pytest_codspeed.instruments.valgrind import (
6572
ValgrindInstrument,
6673
)
6774
from pytest_codspeed.instruments.walltime import WallTimeInstrument
6875

69-
if mode == MeasurementMode.Instrumentation:
76+
if mode == MeasurementMode.Simulation:
7077
return ValgrindInstrument
7178
else:
7279
return WallTimeInstrument

src/pytest_codspeed/instruments/hooks/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ def set_integration(self, name: str, version: str) -> None:
7878
warnings.warn("Failed to set integration name and version", RuntimeWarning)
7979

8080
def is_instrumented(self) -> bool:
81-
"""Check if instrumentation is active."""
81+
"""Check if simulation is active."""
8282
return self.lib.instrument_hooks_is_instrumented(self.instance)

src/pytest_codspeed/instruments/valgrind.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(self, config: CodSpeedConfig) -> None:
3939

4040
def get_instrument_config_str_and_warns(self) -> tuple[str, list[str]]:
4141
config = (
42-
f"mode: instrumentation, "
42+
f"mode: simulation, "
4343
f"callgraph: {'enabled' if SUPPORTS_PERF_TRAMPOLINE else 'not supported'}"
4444
)
4545
warnings = []

src/pytest_codspeed/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def pytest_configure(config: pytest.Config):
115115
if os.environ.get("CODSPEED_RUNNER_MODE") == "walltime":
116116
default_mode = MeasurementMode.WallTime.value
117117
else:
118-
default_mode = MeasurementMode.Instrumentation.value
118+
default_mode = MeasurementMode.Simulation.value
119119
else:
120120
default_mode = MeasurementMode.WallTime.value
121121

tests/test_pytest_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_bench_enabled_header_without_perf(
3434
with codspeed_env():
3535
result = pytester.runpytest()
3636
result.stdout.fnmatch_lines(
37-
["codspeed: * (enabled, mode: instrumentation, callgraph: not supported)"]
37+
["codspeed: * (enabled, mode: simulation, callgraph: not supported)"]
3838
)
3939

4040

tests/test_pytest_plugin_cpu_instrumentation.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_bench_enabled_header_with_perf(
2121
with codspeed_env():
2222
result = pytester.runpytest()
2323
result.stdout.fnmatch_lines(
24-
["codspeed: * (enabled, mode: instrumentation, callgraph: enabled)"]
24+
["codspeed: * (enabled, mode: simulation, callgraph: enabled)"]
2525
)
2626

2727

@@ -36,7 +36,7 @@ def _():
3636
return 1 + 1
3737
"""
3838
)
39-
result = run_pytest_codspeed_with_mode(pytester, MeasurementMode.Instrumentation)
39+
result = run_pytest_codspeed_with_mode(pytester, MeasurementMode.Simulation)
4040
result.stdout.fnmatch_lines(
4141
[
4242
(
@@ -132,7 +132,7 @@ def foo():
132132
benchmark.pedantic(foo, rounds=10, iterations=100)
133133
"""
134134
)
135-
result = run_pytest_codspeed_with_mode(pytester, MeasurementMode.Instrumentation)
135+
result = run_pytest_codspeed_with_mode(pytester, MeasurementMode.Simulation)
136136
result.stdout.fnmatch_lines(
137137
[
138138
"*UserWarning: Valgrind instrument ignores rounds and iterations settings "
@@ -192,8 +192,6 @@ def target(a, b, c):
192192
"""
193193
)
194194
with codspeed_env():
195-
result = run_pytest_codspeed_with_mode(
196-
pytester, MeasurementMode.Instrumentation
197-
)
195+
result = run_pytest_codspeed_with_mode(pytester, MeasurementMode.Simulation)
198196
assert result.ret == 0, "the run should have succeeded"
199197
result.assert_outcomes(passed=1)

0 commit comments

Comments
 (0)