Skip to content

feat(website): split benchmark charts into public/benchmark/{svg,png} with PNG export#307

Merged
samchon merged 3 commits into
masterfrom
feat/website-benchmark-chart-export
Jul 2, 2026
Merged

feat(website): split benchmark charts into public/benchmark/{svg,png} with PNG export#307
samchon merged 3 commits into
masterfrom
feat/website-benchmark-chart-export

Conversation

@samchon

@samchon samchon commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Intent

Move the generated benchmark charts out of the flat website/public/benchmark/ root into dedicated public/benchmark/svg/ and public/benchmark/png/ folders, and publish a PNG sibling for every SVG chart so embeds that reject SVG (dev.to, social cards) can point at ttsc.dev directly.

Scope

  • website/build/graph-benchmark-svg.cjs writes SVGs to public/benchmark/svg/ and, with --png, exports a 2x PNG per chart to public/benchmark/png/. Both folders are created when absent, and only charts whose SVG content changed (or whose PNG is missing) re-render.
  • PNG export launches a headless browser per chart, so it runs at pnpm build (new build:benchmark:png step in prebuild), not pnpm prepare; prepare stays SVG-only (~1.4s when nothing changed).
  • website/build/svg-to-png.cjs becomes a reusable module (renderPng, findBrowser) while keeping its dev.to re-export CLI. findBrowser honors CHROME_BIN/EDGE_BIN and knows the Linux/macOS binary paths, so the website.yml build on ubuntu-latest keeps working with the runner's preinstalled Chrome. With --png a missing browser fails the build instead of silently shipping without PNGs.
  • Chart references follow the new URLs: launch blog post (2 images) and packages/graph/README.md.
  • website/.gitignore swaps the old public/benchmark/graph-*.svg pattern for the two generated folders.

Deferred

  • PNG rendering is sequential (one Chrome launch per chart, ~3-5 min for a full 90-chart render from scratch). A parallel pool could cut this to ~30s if full re-renders become frequent; incremental skip makes it a non-issue for now.

Test plan

  • Deleted both output folders and ran pnpm run build:benchmark:graph: folders auto-created, 90 SVGs written, no PNG work.
  • Ran pnpm run build:benchmark:png after deleting 2 PNGs: only those 2 re-rendered (dimension-verified 2x via the script's IHDR check), 90/90 pairs present.
  • prepare-mode run on unchanged graph.json: 1.4s, zero re-renders.
  • website.yml PR build below exercises the --png path on ubuntu-latest.

🤖 Generated with Claude Code

… with PNG export

Benchmark charts previously landed flat in public/benchmark as SVGs only.
Now build/graph-benchmark-svg.cjs writes SVGs to public/benchmark/svg and,
with --png, exports a 2x PNG sibling per chart to public/benchmark/png via
headless Chrome/Edge (svg-to-png.cjs is now reusable as a module).

PNG export needs a browser and launches one per chart, so it runs at
`pnpm build` (new build:benchmark:png step in prebuild), not `pnpm prepare`;
prepare stays SVG-only and fast. Both steps re-render only charts whose SVG
content changed or whose PNG is missing, and create the output folders when
absent. findBrowser honors CHROME_BIN/EDGE_BIN and knows the Linux/macOS
binary paths so website.yml (ubuntu-latest) keeps working.

Chart references in the launch post and @ttsc/graph README follow the new
/benchmark/svg/ URLs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 2, 2026 07:11
The codegraph and codebase-memory-mcp working clones were checked in as
gitlinks for comparator research; that research is done and the clones no
longer belong in the website tree.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ss Chrome

Chrome launched one process per chart (3-5 min for a full 90-chart render)
and made PNG export depend on a browser binary being installed. resvg
(@resvg/resvg-js, prebuilt native bindings) rasterizes in-process: the same
full render now takes ~37s and works on any machine or runner without a
browser. The dev.to re-export CLI keeps its interface; findBrowser and the
HTML-wrapper screenshot path are gone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@samchon

samchon commented Jul 2, 2026

Copy link
Copy Markdown
Owner Author

Two follow-up commits:

  • 02c012f removes the codegraph / codebase-memory-mcp embedded comparator clones (gitlinks) from website/public/benchmark — the comparator research is done and they no longer belong in the website tree.
  • 6716f67 replaces the headless-Chrome screenshot path with @resvg/resvg-js (prebuilt native bindings, no browser required). A full 90-chart PNG render drops from 3-5 min to ~37s, and PNG export no longer depends on a Chrome/Edge binary existing on the machine or runner. Verified with a from-scratch render (90/90 pairs, exact 2x dimensions via the IHDR check) plus a visual inspection of the output.

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​resvg/​resvg-js@​2.6.2981001008770

View full report

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restructures the website’s generated benchmark chart assets by separating SVG and PNG outputs into dedicated subfolders and adding an automated PNG export path so charts can be embedded in places that don’t accept SVG.

Changes:

  • Update benchmark chart generation to write SVGs to public/benchmark/svg/ and (optionally) export 2x PNG siblings to public/benchmark/png/.
  • Refactor svg-to-png.cjs into a reusable module (renderPng, findBrowser) while keeping CLI behavior.
  • Update documentation/content links and gitignore rules to match the new chart URLs and generated folders.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
website/src/content/blog/i-made-ts-compiler-graph-mcp.mdx Updates embedded chart URLs to the new /benchmark/svg/ path.
website/package.json Adds a build:benchmark:png step and runs it during prebuild.
website/build/svg-to-png.cjs Refactors PNG rendering into reusable exports and expands browser discovery for CI/local.
website/build/graph-benchmark-svg.cjs Writes charts into public/benchmark/svg/ and optionally exports PNGs to public/benchmark/png/ with incremental skipping.
website/.gitignore Ignores the generated public/benchmark/svg/ and public/benchmark/png/ folders.
packages/graph/README.md Updates benchmark chart URL to the new /benchmark/svg/ location.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (changed) fs.writeFileSync(file, content);
const pngFile = path.join(PNG_DIR, name.replace(/\.svg$/, ".png"));
if (changed || !fs.existsSync(pngFile)) pngQueue.push(file);
written += 1;
Comment thread website/build/graph-benchmark-svg.cjs Outdated
Comment on lines +149 to +151
throw new Error(
"[build:graph-svg] --png needs a headless Chrome or Edge, and none was found",
);
@samchon samchon merged commit 2d60de8 into master Jul 2, 2026
34 checks passed
@samchon samchon deleted the feat/website-benchmark-chart-export branch July 2, 2026 07:38
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