Skip to content

refactor(benchmark): measure the built CLI instead of tsx - #189

Merged
luojiyin1987 merged 1 commit into
masterfrom
refactor/benchmark-built-cli
Sep 13, 2026
Merged

luojiyin1987 merged 1 commit into
masterfrom
refactor/benchmark-built-cli

Conversation

@luojiyin1987

@luojiyin1987 luojiyin1987 commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Problem

benchmark-memory.mjs runs node tsx src/lint-md.ts, but batchLint() worker falls back to lib/src/utils/lint-worker.js when the TypeScript source path is not found. This creates a mixed-mode benchmark:

  • Main thread: tsx + TypeScript source
  • Worker thread: compiled JS

Real npm users run node lib/src/lint-md.js for both. The tsx overhead biases absolute RSS and startup numbers.

Solution

Run the built CLI directly:

node lib/src/lint-md.js --threads 4 --fix [files...]

Requires npm run build before running. The script now checks for the built CLI and throws if missing.

Changes

  • Replace tsx invocation with built CLI
  • Add BSD-style /usr/bin/time output parsing as fallback
  • Update usage text to document build prerequisite

Verification

npm run build
node scripts/benchmark-memory.mjs --files 1000 --bytes-per-file 65536 --threads 4 --runs 3 --fix

Closes #190

benchmark-memory.mjs now runs:
  node lib/src/lint-md.js
instead of:
  node tsx src/lint-md.ts

This eliminates tsx runtime overhead and matches real npm usage.
The worker thread path is now fully compiled JS, not a fallback.

Also adds BSD-style /usr/bin/time output parsing as fallback.
Requires `npm run build` before running the benchmark.
@luojiyin1987
luojiyin1987 force-pushed the refactor/benchmark-built-cli branch from 5cc8f34 to 2aa5dbb Compare September 13, 2026 05:28
@luojiyin1987
luojiyin1987 merged commit bd10d11 into master Sep 13, 2026
11 checks passed
@luojiyin1987
luojiyin1987 deleted the refactor/benchmark-built-cli branch September 13, 2026 05:36
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.

refactor(benchmark): measure the built CLI instead of tsx

1 participant