Files
Miguel Ángel 438ea9d59f perf(studio): manual edits stay under 8 ms per frame (#4898)
* ci(studio): measure any edit cases on quiet runners, five runs in parallel

* perf(studio): an undo or save stops re-rendering every panel

* test(studio): the edit bench types one key per frame, as a person does

* fix(studio): the edit bench measures frame work when a task outside the drag has no thread time

* refactor(studio): hooks hand back stable handlers themselves, keeping App.tsx under 600 lines

* test(studio): the edit bench says why a case's frame work is unknown

* fix(studio): the edit bench counts a task without thread time at its wall time

* perf(studio): draw toasts on an opaque surface without backdrop blur

* fix(studio): keep stable handlers bound to the project they were made in

* fix(studio): every stable handler names the project it belongs to

* style(studio): format the stable handler call sites

* refactor(studio): name the timeline editing handler objects before wrapping them
2026-10-02 21:15:19 +00:00

29 lines
1.2 KiB
JavaScript

import { describe, expect, it } from "vitest";
import { smoothness } from "./case.mjs";
const thread = { pid: 1, tid: 2 };
const mark = { name: "edit-bench-end", cat: "blink.user_timing", ts: 1_000_000, ...thread };
const task = (ts, dur, tdur) => ({ name: "RunTask", ph: "X", ts, dur, tdur, ...thread });
// Frame stamps 50, 66 and 82 ms before a mark at 100 ms: trace time 950, 966 and 982 ms.
const rec = (trace) => ({ frames: [50, 66, 82], mark: 100, long: [], trace });
describe("smoothness work per frame", () => {
it("measures the frames when a task outside them lacks thread time", () => {
const s = smoothness(rec([mark, task(900_000, 10_000), task(960_000, 4_000, 2_000)]));
expect(s.work).toEqual([2, 0]);
expect(s.wallTimed).toBe(0);
});
it("counts a task inside the frames that lacks thread time at its wall time", () => {
const s = smoothness(rec([mark, task(960_000, 4_000)]));
expect(s.work).toEqual([4, 0]);
expect(s.wallTimed).toBe(1);
});
it("leaves the work unknown without the end mark", () => {
const s = smoothness(rec([task(960_000, 4_000, 4_000)]));
expect(s.work).toBeNull();
expect(s.unknown).toBe("no end mark in the trace");
});
});