bench(nad): reproducible benchmarks for the adaptive-zoom writer perf work#11
Draft
gautierbureau wants to merge 1 commit into
Draft
Conversation
…perf work Add a benchmarks/ suite measuring the three performance changes stacked on the adaptive-zoom SVG-writer branch: - nad-metadata-index-bench.mjs: replays the writer's per-element metadata access pattern with linear scans vs Map indices (self-contained; the indexed functions mirror metadata-utils.ts). Shows O(n^2) -> O(n): pegase 33ms -> 0.3ms. - nad-geometry-precision-bench.mjs: coordinate-text size at precision 0-3 on real pegase geometry, raw and gzipped. - nad-lazy-mount-bench.mjs: real headless-Chromium eager vs lazy off-screen viewer construction; N/visible-x fewer constructions on load (4x at N=8), saving ~2.2s on an 8-viewer page via the client-writer path. README.md documents how to run each and records the measured numbers, noting that absolute times are machine-dependent while the ratios are portable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T1fMV9gtgHLBKoSAShYSdA
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.
What
A
benchmarks/suite that measures — reproducibly — the three performance PRs stacked onintegration/nad_create_svg_adaptive_zoom(powsybl#423). Additive only; no product code changes. Companion to #7 (metadata indexing), #8 (geometry precision) and #9 (lazyMount); the numbers in those PR descriptions come from this suite.Benchmarks
nad-metadata-index-bench.mjsfind/filtervs Map indexnad-geometry-precision-bench.mjsnad-lazy-mount-bench.mjsplaywright-coreThe two node benches are self-contained (the compared implementations are inlined and mirror the shipped code, which is covered byte-for-byte by unit tests). The lazy-mount bench drives the real viewer via the demo server (Vite
/@fs), and can exercise either the raw-SVG-injection or the powsybl#423 client-writer construction path (CREATE_SVG_FROM_METADATA=1).Recorded results (headless Chromium, dev mode)
Absolute times are machine/run-dependent; the ratios are the portable figures.
Metadata indexing — writer access pattern,
find/filtervs Map index:Old ~quadruples per doubling of N (O(n²)); indexed grows ~linearly.
Geometry precision — coordinate-text bytes on real pegase geometry:
(The whole-document figures measured by the writer's own size test — 168.5 KB gzip → 156.0 / 140.8 KB — are in #8; smaller percentages there because coordinates are only part of the SVG.)
Lazy off-screen construction — real browser, N viewers stacked in one viewport:
Ratio ≈
N / visible, so a page showing ~1 of N approaches an N× reduction; all N build on demand while scrolling. The client-writer path costs ~9× more per viewer than raw injection — which is exactly where the metadata indexing (#7) pays off.Notes
Draft; base is the in-progress adaptive-zoom branch.
playwright-coreand (for the writer's own size test referenced above)fast-xml-parserare dev-only and installed--no-save— not added topackage.jsonhere.🤖 Generated with Claude Code
Generated by Claude Code