test(package/codegen): add benchmark with sourcemaps - #25772
Merged
graphite-app[bot] merged 1 commit intoAug 18, 2026
Merged
graphite-app[bot] merged 1 commit into
graphite-app[bot] merged 1 commit into
Conversation
Member
Author
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Vitest benchmarks in packages/codegen to measure the performance impact of source map support in oxc-codegen, including a variant that skips the final mapping emission pass to isolate the printer’s mapping-recording overhead.
Changes:
- Add a new benchmark build flag (
BENCHMARKS) and a benchmarks-onlyskipSourcemapGenerationswitch to optionally skipemitMappingsin source-map builds. - Add a shared AST
locsynthesizer utility and reuse it from the existing source map tests and the new benchmarks. - Add
@jridgewell/gen-mappingas a dev dependency and wire uppnpm run benchto build the benchmark variant and run Vitest benches.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Locks the new @jridgewell/gen-mapping dev dependency for codegen benchmarks. |
| packages/codegen/tsdown.config.ts | Introduces BENCHMARKS global define used to enable benchmark-only behavior in builds. |
| packages/codegen/test/utils/locs.ts | New shared helper to synthesize loc data from start/end offsets for sourcemap paths. |
| packages/codegen/test/source-maps.test.ts | Switches tests to use the shared addLocs helper. |
| packages/codegen/src-js/print/index.ts | Adds benchmark-only gate to optionally skip emitMappings (skipSourcemapGeneration). |
| packages/codegen/src-js/globals.d.ts | Declares BENCHMARKS build-time global for the JS printer builds. |
| packages/codegen/package.json | Adds build-bench/bench scripts and the @jridgewell/gen-mapping dev dependency. |
| packages/codegen/bench.bench.ts | Adds 3 benchmark variants (no sourcemaps / full sourcemaps / sourcemaps without emitting). |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
camc314
reviewed
Aug 17, 2026
overlookmotel
force-pushed
the
om/08-15-test_package_codegen_add_benchmark_with_sourcemaps
branch
2 times, most recently
from
August 18, 2026 16:06
9efb397 to
e3b6c62
Compare
This was referenced Aug 18, 2026
perf(packages/codegen): remove redundant setting of
last in printImportAttributes and printIf
#25882
Merged
Merged
Member
Author
|
@camc314 Now rebased on current main. |
camc314
approved these changes
Aug 18, 2026
Contributor
Merge activity
|
Add benchmarks for source maps in `oxc-codegen`. 2 benchmarks: 1. Full end-to-end. 2. Without the actual sourcemap generation at the end. The 2nd is to measure the overhead that pushing to the sourcemap arrays adds while printing in isolation.
graphite-app
Bot
force-pushed
the
om/08-15-test_package_codegen_add_benchmark_with_sourcemaps
branch
from
August 18, 2026 16:17
e3b6c62 to
ea28801
Compare
graphite-app
Bot
deleted the
om/08-15-test_package_codegen_add_benchmark_with_sourcemaps
branch
August 18, 2026 16:24
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.

Add benchmarks for source maps in
oxc-codegen.2 benchmarks:
The 2nd is to measure the overhead that pushing to the sourcemap arrays adds while printing in isolation.