|
7 | 7 | regression_messages, |
8 | 8 | skip_reason, |
9 | 9 | ) |
| 10 | +from scripts.release_performance.constants import BENCHMARK_COMMANDS |
10 | 11 | from scripts.release_performance.models import BenchmarkCommand, MetricVerdict |
11 | 12 | from tests.unit.scripts.release_performance._helpers._test_types import ( |
| 13 | + ConfiguredTimeLimitTestCase, |
12 | 14 | MetricVerdictTestCase, |
13 | 15 | SkipReasonTestCase, |
14 | 16 | ) |
@@ -221,5 +223,64 @@ def test_given_command_minimum_version_when_checking_versions_then_explains_skip |
221 | 223 | assert reason == test_case.expected_reason |
222 | 224 |
|
223 | 225 |
|
| 226 | +@pytest.mark.parametrize( |
| 227 | + "test_case", |
| 228 | + ( |
| 229 | + ConfiguredTimeLimitTestCase( |
| 230 | + description="a dense one-model edit within the edit limit passes", |
| 231 | + command="dense compile (one-model edit)", |
| 232 | + wall_ratio=1.232, |
| 233 | + expected_regressed=False, |
| 234 | + ), |
| 235 | + ConfiguredTimeLimitTestCase( |
| 236 | + description="a one-model edit within the edit limit passes", |
| 237 | + command="compile (one-model edit)", |
| 238 | + wall_ratio=1.24, |
| 239 | + expected_regressed=False, |
| 240 | + ), |
| 241 | + ConfiguredTimeLimitTestCase( |
| 242 | + description="a dense one-model edit beyond the edit limit fails", |
| 243 | + command="dense compile (one-model edit)", |
| 244 | + wall_ratio=1.26, |
| 245 | + expected_regressed=True, |
| 246 | + ), |
| 247 | + ConfiguredTimeLimitTestCase( |
| 248 | + description="an unchanged warm compile keeps the tighter compile limit", |
| 249 | + command="dense compile (warm cache)", |
| 250 | + wall_ratio=1.232, |
| 251 | + expected_regressed=True, |
| 252 | + ), |
| 253 | + ConfiguredTimeLimitTestCase( |
| 254 | + description="a cold compile keeps the tighter compile limit", |
| 255 | + command="dense compile (no cache)", |
| 256 | + wall_ratio=1.16, |
| 257 | + expected_regressed=True, |
| 258 | + ), |
| 259 | + ), |
| 260 | + ids=lambda case: case.description, |
| 261 | +) |
| 262 | +def test_given_configured_command_when_judging_time_then_its_own_limit_applies( |
| 263 | + test_case: ConfiguredTimeLimitTestCase, |
| 264 | +) -> None: |
| 265 | + configured: BenchmarkCommand = {command.name: command for command in BENCHMARK_COMMANDS}[ |
| 266 | + test_case.command |
| 267 | + ] |
| 268 | + wall: float = 10.0 * test_case.wall_ratio |
| 269 | + |
| 270 | + verdicts: tuple[MetricVerdict, ...] = metric_verdicts( |
| 271 | + comparison=comparison( |
| 272 | + name=configured.name, |
| 273 | + baseline=((10.0, 10.0, 400),) * 3, |
| 274 | + candidate=((wall, wall, 400),) * 3, |
| 275 | + max_time_ratio=configured.max_time_ratio, |
| 276 | + ) |
| 277 | + ) |
| 278 | + |
| 279 | + assert (verdicts[0].regressed, verdicts[1].regressed) == ( |
| 280 | + test_case.expected_regressed, |
| 281 | + test_case.expected_regressed, |
| 282 | + ) |
| 283 | + |
| 284 | + |
224 | 285 | if __name__ == "__main__": |
225 | 286 | pytest.main([__file__, "-vv"]) |
0 commit comments