Benchmark TSX: the classic runtime and the JSX-preserving strip #2

Closed natemoo.re
targeting jsx from bench-tsx
Closed opened by and assigned to natemoo.re
targeting jsx from bench-tsx

Adds TSX to the benchmarks: a classic-runtime transform and a JSX-preserving strip, timed against every tool that parses TSX.

What changes #

  • scripts/oss.sh also checks out .tsx files for Sentry's frontend and Excalidraw.
  • node scripts/oss-sample.mjs tsx draws a seeded 10MB sample of 1,603 files from them, written to corpus/oss-tsx-sample.json (gitignored, like the other samples).
  • bench/throughput.mjs --mode=jsx and --mode=jsx-preserve time each tool's TSX path, registered in bench/tools.mjs: typestrip, oxc-transform, sucrase, esbuild, ts.transpileModule, and ts-blank-space for preserve.
  • docs/benchmarks.md publishes the two tables.

Results #

Median of 2 to 4 runs, at a load average of 5 to 10:

typestrip oxc-transform † sucrase esbuild † ts.transpileModule
classic runtime, MB/s 67.3 50.4 16.6 5.8 2.5
JSX kept, MB/s 64.3 52.6 19.4 6.7 2.4

† Native code. typestrip is 1.3× oxc-transform when transforming and 1.2× when keeping the JSX. oxc-transform uses the least memory. No tool fails any of the 1,603 files.

Verification #

All 9,368 .tsx files in the two projects pass the JSX judge in both modes.

Stacked on #1.

Commits 0