Repository navigation
feat(bench): parsec-js had no numbers against oxc or swc - #191
Open
jamesconwaydev wants to merge 2 commits into
Open
jamesconwaydev wants to merge 2 commits into
jamesconwaydev wants to merge 2 commits into
Conversation
Nothing timed the JavaScript parser, so whether it was fast, or how it stood against the parsers people use, was a guess. - `parsec-html-bench js` times parsec-js, oxc_parser 0.157.0 and swc_ecma_parser 47.0.0, pinned exactly, on the same strings: MB/s from the median of at least five runs, and peak memory from the counting allocator the HTML tables use. - The corpus: react-dom 19.2.0, three.js 0.181.0 as a module and typescript.js 5.9.3, listed with their SHA-256 in bench/scripts.txt and fetched by fetch-pages.sh, and each real page's inline scripts. - `parsec-html-bench js-dump DIR` writes every source out, and compare-acorn.sh --bench uses it to check each tree against acorn's. - README's JavaScript row and ROADMAP's M10 have the numbers: 1.26 times swc's speed, 0.57 times oxc's, less memory than either.
This was referenced Nov 21, 2026
Brings the branch onto its new base after the pull request below it merged.
This branch has not been deployed
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.
Fixes #156. Fixes #152.
Builds on #189, which this is based on; once that merges, this is rebased onto its base.
Problem. Nothing timed parsec-js. Whether it was quick, and how it stood against
oxc_parserandswc_ecma_parser, which are what a Rust project would reach for, was a guess. #152's last check was waiting too: that the ESTree output matches acorn's on the bench corpus.Change.
bench/src/js.rs, run withparsec-html-bench js: parsec-js, oxc_parser 0.157.0 and swc_ecma_parser 47.0.0 (with swc_common 27.0.0), pinned with=inbench/Cargo.toml, on the same strings. Each builds its whole tree and keeps it until the clock stops. A time is the median of at least five runs after a warm-up, more for small sources. Peak memory comes from the counting allocator the HTML tables use.bench/scripts.txtpins react-dom 19.2.0's production client, three.js 0.181.0 (a module) and typescript.js 5.9.3 on jsDelivr, with their SHA-256, andbench/fetch-pages.shfetches them with the pages and stylesheets. The inline<script>elements of each real page are found with Parsec's own selectors, one source per page, each script parsed on its own. One any parser rejects would be left out and counted; none was.parsec-html-bench js-dump DIRwrites every source out, andcrates/parsec-js/scripts/compare-acorn.sh --benchuses it to compare each tree with acorn 8.19.0's. That's the check The AST: arena nodes, spans, ESTree JSON out #152 asked for. It's a script, not a CI step: it needs the fetched corpus and Node.Results. Apple M2 Max, macOS, Rust 1.100, load average 6.5:
Parsec is 1.26 times swc's speed and 0.57 times oxc's, and holds the least memory on every source. An earlier run gave the same totals within 2%.
Tests.
compare-acorn.sh --bench: 107 sources (3 bundles, 104 inline scripts), all the same as acorn's.cargo fmt --check,cargo clippy --release -D warningsandcargo deny check licenses bans sourcesonbench/Cargo.toml, and the"shop 1 MB" "unclosed tables"run. The oxc and swc trees are MIT and Apache-2.0, anddeny.tomltakes them with no changes.The wiki. This is for the Benchmarks page once this merges; I'll push it to the wiki then.
Benchmarks.md patch