|
34 | 34 | FALLBACK_MODEL = "gpt-4o-mini" |
35 | 35 | FALLBACK_PROVIDER = "openai" |
36 | 36 |
|
| 37 | +# Wall-clock start for each feature (on ``Feature``; survives Behave context resets). |
| 38 | +_E2E_FEATURE_PERF_START_ATTR = "_lightspeed_e2e_feature_perf_start" |
| 39 | + |
37 | 40 |
|
38 | 41 | def _fetch_models_from_service() -> dict: |
39 | 42 | """Query /v1/models endpoint and return first LLM model. |
@@ -349,7 +352,11 @@ def before_feature(context: Context, feature: Feature) -> None: |
349 | 352 |
|
350 | 353 | Per-feature setup that is not expressed in Gherkin (e.g. feedback cleanup state). |
351 | 354 | Lightspeed YAML is applied in feature Backgrounds via ``configure_service``. |
| 355 | +
|
| 356 | + Records monotonic start time on ``feature`` for duration logging in |
| 357 | + ``after_feature`` (includes scenarios and feature teardown). |
352 | 358 | """ |
| 359 | + setattr(feature, _E2E_FEATURE_PERF_START_ATTR, time.perf_counter()) |
353 | 360 | reset_active_lightspeed_stack_config_basename() |
354 | 361 | context.active_lightspeed_stack_config_basename = None |
355 | 362 | # One real Llama disruption per feature (module-level flag; survives context resets) |
@@ -398,3 +405,19 @@ def after_feature(context: Context, feature: Feature) -> None: |
398 | 405 |
|
399 | 406 | _stop_proxy(context, "tunnel_proxy", "proxy_loop") |
400 | 407 | _stop_proxy(context, "interception_proxy", "interception_proxy_loop") |
| 408 | + |
| 409 | + start = getattr(feature, _E2E_FEATURE_PERF_START_ATTR, None) |
| 410 | + if start is not None: |
| 411 | + elapsed_s = time.perf_counter() - start |
| 412 | + try: |
| 413 | + delattr(feature, _E2E_FEATURE_PERF_START_ATTR) |
| 414 | + except AttributeError: |
| 415 | + pass |
| 416 | + feat_path = getattr(feature, "filename", "") or "" |
| 417 | + label = os.path.basename(feat_path) if feat_path else feature.name |
| 418 | + print(f"[e2e feature timing] {elapsed_s:.2f}s {label}", flush=True) |
| 419 | + |
| 420 | + |
| 421 | +# Behave captures hook stdout by default; output is only shown in some failure paths. |
| 422 | +# Disable capture so feature timing lines always appear on the real console/CI log. |
| 423 | +after_feature.capture = False # type: ignore[attr-defined] |
0 commit comments