Skip to content

test(bench): add graph.html render benchmark + baseline - #12

Merged
taylor009 merged 1 commit into
taylor009:mainfrom
muqsitnawaz:bench-harness
Jul 17, 2026
Merged

test(bench): add graph.html render benchmark + baseline#12
taylor009 merged 1 commit into
taylor009:mainfrom
muqsitnawaz:bench-harness

Conversation

@muqsitnawaz

Copy link
Copy Markdown
Contributor

A reproducible benchmark for the interactive graph.html viewer, so the rendering optimizations coming next can be measured, not asserted. No product code changes — adds a bench/ harness only.

What it measures

Per graph size, without modifying the generated HTML:

  • payloadgraph.html size on disk
  • DOMContentLoaded — document load/parse time
  • time-to-settle — wall-clock until the force-directed layout stops animating (detected by wrapping requestAnimationFrame; settled = no frame scheduled for 400 ms)
  • peak JS heapperformance.memory.usedJSHeapSize

Baseline (this machine) — the O(N²) main-thread force sim, quantified

nodes edges payload (MB) DOMContentLoaded (ms) time-to-settle peak heap (MB)
1,005 2,400 0.81 152 2.3 s 9.5
5,001 12,000 3.89 175 14.9 s 12.1
10,005 24,000 7.8 219 35.2 s 24.8

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 a graph.html, detects settle, prints one JSON row.
  • bench/run.sh — generates a tree per size, scans with cgraph, runs the driver, writes baseline-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).

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.
@taylor009
taylor009 merged commit 1e5e22a into taylor009:main Jul 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants