Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
81 lines
3.0 KiB
Python
81 lines
3.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Report p50/p95 wall-clock latency for a completed ReelForge golden run.
|
|
|
|
Feed this command a JSON or JSONL results artifact produced by the live 10-job
|
|
golden runner. Every row must contain a numeric ``duration_s``; optional job
|
|
metadata is ignored so CI/CD, a worker wrapper, or an operator can write it.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import math
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def percentile(values: list[float], fraction: float) -> float:
|
|
"""Return a linearly interpolated percentile for non-empty sorted samples."""
|
|
ordered = sorted(values)
|
|
position = (len(ordered) - 1) * fraction
|
|
lower = math.floor(position)
|
|
upper = math.ceil(position)
|
|
if lower == upper:
|
|
return ordered[lower]
|
|
return ordered[lower] + (ordered[upper] - ordered[lower]) * (position - lower)
|
|
|
|
|
|
def load_durations(path: Path) -> list[float]:
|
|
"""Load JSON array/object or JSONL benchmark rows, rejecting invalid samples."""
|
|
raw = path.read_text(encoding="utf-8").strip()
|
|
if not raw:
|
|
raise ValueError("benchmark results file is empty")
|
|
try:
|
|
decoded = json.loads(raw)
|
|
rows = decoded.get("results", []) if isinstance(decoded, dict) else decoded
|
|
except json.JSONDecodeError:
|
|
rows = [json.loads(line) for line in raw.splitlines() if line.strip()]
|
|
if not isinstance(rows, list):
|
|
raise ValueError("benchmark results must be an array or JSONL rows")
|
|
durations: list[float] = []
|
|
for index, row in enumerate(rows, start=1):
|
|
value = row.get("duration_s") if isinstance(row, dict) else None
|
|
try:
|
|
seconds = float(value)
|
|
except (TypeError, ValueError) as exc:
|
|
raise ValueError(f"row {index} has no numeric duration_s") from exc
|
|
if not math.isfinite(seconds) or seconds < 0:
|
|
raise ValueError(f"row {index} has invalid duration_s")
|
|
durations.append(seconds)
|
|
if not durations:
|
|
raise ValueError("benchmark results contain no samples")
|
|
return durations
|
|
|
|
|
|
def main(argv: list[str] | None = None) -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("results", type=Path, help="JSON/JSONL golden-run result artifact")
|
|
parser.add_argument("--expected", type=int, default=10, help="expected sample count")
|
|
args = parser.parse_args(argv)
|
|
try:
|
|
durations = load_durations(args.results)
|
|
except (OSError, ValueError, json.JSONDecodeError) as exc:
|
|
print(f"benchmark error: {exc}", file=sys.stderr)
|
|
return 2
|
|
if args.expected > 0 and len(durations) != args.expected:
|
|
print(
|
|
f"benchmark error: expected {args.expected} samples, got {len(durations)}",
|
|
file=sys.stderr,
|
|
)
|
|
return 2
|
|
print(
|
|
f"samples={len(durations)} p50_s={percentile(durations, 0.50):.3f} "
|
|
f"p95_s={percentile(durations, 0.95):.3f} max_s={max(durations):.3f}"
|
|
)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|