test(bench): add graph.html render benchmark + baseline - #12
Merged
Conversation
Quantifies the interactive viewer's client-side cost so the rendering optimizations can be measured, not asserted. Measures payload, load time, force-sim time-to-settle (via a requestAnimationFrame wrapper, no HTML change), and peak JS heap across graph sizes. Baseline on this machine shows the O(N^2) main-thread force sim clearly: | nodes | settle | payload | | 1,005 | 2.3 s | 0.8 MB | | 5,001 | 14.9 s | 3.9 MB | | 10,005 | 35.2 s | 7.8 MB | 35 s of pinned main thread to lay out a 10k-node graph. Pieces: gen_tree.py (deterministic synthetic project), bench.mjs (Playwright driver), run.sh.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A reproducible benchmark for the interactive
graph.htmlviewer, so the rendering optimizations coming next can be measured, not asserted. No product code changes — adds abench/harness only.What it measures
Per graph size, without modifying the generated HTML:
graph.htmlsize on diskrequestAnimationFrame; settled = no frame scheduled for 400 ms)performance.memory.usedJSHeapSizeBaseline (this machine) — the O(N²) main-thread force sim, quantified
Layout settle scales ~quadratically (5x nodes → ~6.5x time); a 10k-node graph pins the main thread for 35 s on every page open. This is the number the follow-up server-side-layout PR targets (precompute in C++ → browser renders a static layout, settle → ~0).
Pieces
bench/gen_tree.py— deterministic synthetic Python project of ~N nodes, grouped into packages (communities) with cross-file calls/imports.bench/bench.mjs— Playwright driver; loads agraph.html, detects settle, prints one JSON row.bench/run.sh— generates a tree per size, scans withcgraph, runs the driver, writesbaseline-report.md.Requires Python 3, Node, and Playwright chromium (
bunx playwright install chromium). Part of a rendering speed-up series (dependency-free; server-side igraph layout + Canvas culling to follow).