|
| 1 | +Per-Run Step Timeline (waterfall + bottleneck steps) |
| 2 | +==================================================== |
| 3 | + |
| 4 | +The action profiler aggregates timings by step *name* across many runs — great |
| 5 | +for "which action is slow on average", useless for "why was *this* run slow". A |
| 6 | +single run is an ordered timeline: step A ran, then B, then C, and one of them |
| 7 | +dominated. ``step_timeline`` turns one run's steps into a waterfall (each step's |
| 8 | +offset from the start, its duration and its share of the total) and ranks the |
| 9 | +bottleneck steps, so you can read a single slow run instead of an average. |
| 10 | + |
| 11 | +* :func:`build_timeline` — the waterfall + total / busy / bottleneck / |
| 12 | + parallelism, |
| 13 | +* :func:`critical_steps` — the steps that dominate the run, longest first. |
| 14 | + |
| 15 | +A step is any dict with a name (default ``"name"``) and a ``duration``; an |
| 16 | +optional ``start`` places it on an absolute timeline (overlapping / parallel |
| 17 | +steps), else steps are laid out back-to-back. Pure standard library; no device, |
| 18 | +no ``PySide6``. |
| 19 | + |
| 20 | +Headless API |
| 21 | +------------ |
| 22 | + |
| 23 | +.. code-block:: python |
| 24 | +
|
| 25 | + from je_auto_control import build_timeline, critical_steps |
| 26 | +
|
| 27 | + steps = [{"name": "login", "duration": 1.0}, |
| 28 | + {"name": "load_dashboard", "duration": 4.0}, |
| 29 | + {"name": "submit", "duration": 1.0}] |
| 30 | +
|
| 31 | + build_timeline(steps) |
| 32 | + # {"steps": [{"name": "login", "offset": 0.0, "duration": 1.0, "pct": 16.7}, |
| 33 | + # {"name": "load_dashboard", "offset": 1.0, ..., "pct": 66.7}, ...], |
| 34 | + # "total": 6.0, "busy": 6.0, |
| 35 | + # "bottleneck": {"name": "load_dashboard", "duration": 4.0}, |
| 36 | + # "parallelism": 1.0} |
| 37 | +
|
| 38 | + critical_steps(steps, top=2) |
| 39 | + # [{"name": "load_dashboard", "duration": 4.0, "pct": 66.7}, |
| 40 | + # {"name": "login", "duration": 1.0, "pct": 16.7}] |
| 41 | +
|
| 42 | +``total`` is the wall-clock span, ``busy`` the summed step time; ``parallelism`` = |
| 43 | +busy / total is ``1.0`` for a purely sequential run and ``> 1`` when steps overlap |
| 44 | +(supply ``start`` times). ``pct`` is each step's share of the total time. |
| 45 | + |
| 46 | +Executor commands |
| 47 | +----------------- |
| 48 | + |
| 49 | +``AC_build_timeline`` (``steps``) and ``AC_critical_steps`` (``steps`` / ``top``). |
| 50 | +They are exposed as read-only ``ac_*`` MCP tools and as Script Builder commands |
| 51 | +under **Testing**. |
0 commit comments