# Reproduce the captured measurement

This is a scratch real-app performance proof for [#42233](https://github.com/pingdotgg/t3code/pull/42233). Nothing here is a test result or a standalone browser benchmark. The unchanged function is timed at its actual call site in the real Code tab.

1. Create separate checkouts of base [fdce61c022](https://github.com/pingdotgg/t3code/commit/fdce61c02203278a4b200798e50a714843a0574d) and head [84c705f03b](https://github.com/pingdotgg/t3code/commit/84c705f03b57208b2bae6810334fa822001d93d5). Run `vp i` in each.
2. Before starting each server, run `python3 prepare-proof.py <checkout>`. It installs the identical temporary synthetic PR-read fixture and identical timing wrapper in both checkouts. It DOES NOT modify `packages/client-runtime/src/diffFileOrder.ts`. The fixture replaces isolated-server PR read methods (including credential routing); it does not contact a live forge. The actual app's authenticated RPC and HTTP transports, diff parser, React Code tab, client caches, ordering function, and renderer run normally. Do not use this fixture outside isolated proof servers.
3. Start each with `T3CODE_DEV_SEED=0 vp run dev` from its own checkout. Pair each browser tab using its printed URL. Fresh default threads are created by dev startup. Use Linux Chromium, 1280x800, light theme. Open a synthetic PR through `useRightPanelStore.getState().openPullRequest` with the current thread ref and its project id, repository `proof/diff-files`, number 1000, detailTab `code`. Maximize the panel and collapse the sidebar using their app buttons. This initial setup is outside the measured sample set.
4. In each paired tab, set `window.__proofBatch=4000; window.__proofRepeats=2`, then evaluate `drive-browser.js`. These are two warm-up rounds. The driver opens a distinct PR reference for every load and clicks the real Code tab button. Synthetic PR number modulo 10 selects the graph: 0 = 1000 files/no imports, 1 = 1000/reverse chain, 2 = 2000/reverse chain, 3 = 2000/cycle. Files are `src/file0000.ts` onwards; chains import the next numbered file and cycles close the last edge to zero.
5. Run each side sequentially on the same machine. Set `window.__proofBatch=5000; window.__proofRepeats=9; window.__proofResult=null`, start a tab recording, then evaluate `drive-browser.js` asynchronously. For tools with a 15-second evaluation limit, assign the returned promise to `window.__proofTask` and collect `window.__proofResult` after completion instead of awaiting the whole run in one tool call. There are 36 measured new diff loads on each side, after the warm-ups. The timer surrounds only the unchanged ordering function in `PullRequestCodeTab.diffModel`; storing the output and generating User Timing entries happen after the timer ends. This is function time, not total tab-load latency or a sampled CPU profile.
6. Evaluate `export-browser.js` in each tab and save its gzipBase64 result as `base-browser-results.json` / `head-browser-results.json` after base64 decoding and gunzip. If the tool has a 64 KB limit, retain the object on `window.__proofExport` and retrieve `gzipBase64` in 48,000-character chunks. Raw exports include every full input and output path array, not just a digest.
7. Run `python3 compare.py <capture-directory>`. It compares every complete input and output array across both commits and verifies all expected files are retained. Its report includes medians, every raw sample, full min/max ranges, output SHA-256s, and whether the median gain exceeds both full ranges. No outlier is removed. Capture the completed Code tab after two screenshots at least 500 ms apart are byte-identical. The submitted stills passed that check and were visually inspected; both recordings were inspected using frame contact sheets.
8. Optional supplemental Node measurement: `node node-comparison.mjs <base>/packages/client-runtime/src/diffFileOrder.ts <head>/packages/client-runtime/src/diffFileOrder.ts <output.json>`. Node 26.13.1 on this Linux x86_64 machine; two warm-ups and nine recorded timings, alternating side order. This does not replace the real-app evidence.

Environment: Linux x86_64, Chrome 158.0.0.0, AMD EPYC 4465P, 8 logical CPUs allocated, 1280x800, light theme; both dev servers on the same machine. The ordering modules' working file hashes matched their respective committed blobs before and after measurement.

Result: exact file ordering on all 36 pairs. The 2000-file chain and cycle exceed even the full run-to-run spread on both sides. The 1000-file cases improve in median but do not exceed the base's full spread. Live-forge network latency, desktop/mobile surfaces, total load latency, asymptotic bounds, and memory bounds were not measured.
