Skip to content

Benchmarks

Parsec against Lexbor’s own C and html5ever, in one process, on the same strings. On 13 real pages Parsec parses 1.5 times as many megabytes a second as Lexbor, is ahead on every page, and holds less memory on each. Over the same pages its selectors are 3.2 times as fast as Lexbor’s. On the links in those pages, its URL parser is 2.28 times as fast as Lexbor’s and 1.33 times as fast as Ada’s. On real stylesheets it tokenizes 1.85 times as fast as Lexbor’s CSS module and parses 1.9 times as fast, and parses 1.08 times as fast as Servo’s cssparser. Its JavaScript parser is 1.05 times as fast as oxc’s and 2.6 times as fast as swc’s over its corpus, with less memory than either, though oxc is still ahead on the smallest inline scripts; its lexer alone is 1.06 times as fast as swc’s and 0.61 times as fast as oxc’s. It’s ahead on all eight hostile inputs too, and they’re in the tables below with the rest.

bench/ is its own Cargo workspace, so the test job on three operating systems never builds Lexbor’s C.

  • Lexbor 3.0.1 comes in as a git submodule at its release tag and is built by CMake with its own default flags (-O2, Release), as a static library. The benchmark declares the three functions it needs: lxb_html_document_create, lxb_html_document_parse and lxb_html_document_destroy.
  • html5ever 0.40.1 builds markup5ever_rcdom’s RcDom, the tree its own project uses for tests.
  • Parsec is parsec::parse(html, false).

Each parser gets the same Rust string, already in memory, and builds a whole document with scripting off, which is Lexbor’s default. Freeing the document isn’t timed. After three warm-up runs, a time is the median of at least 30 runs; small pages get more, up to half a second’s worth. MB/s is the page’s size over that median.

Peak memory is how much the heap grew while one document was built and held. The benchmark’s global allocator counts every allocation, and Lexbor’s malloc, realloc, calloc and free are sent through the same allocator with lexbor_memory_setup, so all three are counted the same way. Lexbor sets aside memory pools up front, which is part of why its small pages look large.

The real pages are 13 snapshots from the Internet Archive, fetched raw and checked against SHA-256 hashes in bench/pages.txt. The repository holds their addresses, not the pages. bench/fetch-pages.sh downloads them into bench/corpus/. The shop listings are generated in bench/src/pages.rs, the same shape as Netweir’s benchmark page. The hostile inputs are the eight from crates/parsec/examples/hostile.rs (Limits and hostile input). Each runs in a child process with a two-minute limit, so a parser that hangs or crashes shows up as that instead of stopping the table, and a parse that takes over a second is timed five times rather than 30.

Page Size Parsec MB/s Lexbor MB/s html5ever MB/s Parsec peak Lexbor peak html5ever peak Parsec vs Lexbor
Wikipedia: HTML 0.81 MB 568 297 97 3.2 MB 8.7 MB 5.1 MB 1.91×
Wikipedia: countries by population 1.39 MB 698 351 110 5.6 MB 12.8 MB 7.5 MB 1.99×
MDN: HTML 0.19 MB 567 385 101 0.7 MB 2.0 MB 1.0 MB 1.47×
GitHub: rust-lang/rust 0.33 MB 642 357 103 1.3 MB 3.3 MB 1.6 MB 1.80×
BBC News 0.40 MB 1,621 684 200 1.6 MB 2.6 MB 1.3 MB 2.37×
Hacker News 0.04 MB 321 198 58 0.1 MB 1.5 MB 0.4 MB 1.62×
Stack Overflow question 1.16 MB 676 348 100 4.6 MB 9.5 MB 6.4 MB 1.94×
Python docs: built-in types 0.77 MB 308 186 58 4.6 MB 12.4 MB 9.5 MB 1.66×
New York Times 1.57 MB 1,783 673 237 6.3 MB 7.3 MB 4.3 MB 2.65×
Reddit: r/programming 0.58 MB 1,438 700 206 2.4 MB 3.0 MB 1.7 MB 2.05×
eBay 0.53 MB 1,130 535 180 2.2 MB 3.6 MB 1.9 MB 2.11×
HTML Standard: parsing 0.83 MB 407 238 91 3.2 MB 9.5 MB 7.2 MB 1.71×
HTML Standard, one page 15.78 MB 297 206 71 94.1 MB 195.5 MB 162.4 MB 1.44×
All 13 24.36 MB 370 242 82 1.53×

“All 13” is every page’s bytes over the sum of their medians, so the big spec page weighs most. The gap is widest on the New York Times, BBC News and eBay, and narrowest on the one-page HTML Standard and MDN. html5ever holds less memory than Parsec on four pages: BBC News, the New York Times, Reddit and eBay.

Page Parsec MB/s Lexbor MB/s html5ever MB/s Parsec peak Lexbor peak html5ever peak Parsec vs Lexbor
1 MB 528 260 78 3.9 MB 12.1 MB 8.4 MB 2.03×
10 MB 532 261 78 39.2 MB 113.4 MB 83.4 MB 2.04×

Times below 1 MB/s are given in seconds per parse instead.

Input Size Parsec Lexbor html5ever Parsec vs Lexbor
unclosed divs 0.40 MB 131 MB/s 5.2 s 8.8 s 1,705×
unclosed tables 0.28 MB 155 MB/s 93 MB/s 34 MB/s 1.66×
nested inline 0.48 MB 147 MB/s 101 MB/s 34 MB/s 1.45×
formatting then paragraphs 0.02 MB 68 MB/s 29 MB/s 5 MB/s 2.33×
distinct formatting per p 0.28 MB 29 MB/s 26 MB/s 11 MB/s 1.11×
misnested a 0.28 MB 61 MB/s 39 MB/s 20 MB/s 1.57×
adoption 0.16 MB 60 MB/s 0.6 s 1.1 s 241×
table foster 0.30 MB 89 MB/s 60 MB/s 27 MB/s 1.48×

80,000 unclosed <div>s take Parsec 3 ms and Lexbor 5.2 seconds: Lexbor’s work grows with the square of the depth there. Parsec is ahead on all eight. The two formatting rows used to go Lexbor’s way, at 0.56× and 0.86×: both keep a long list of formatting elements open across thousands of paragraphs, and every new formatting tag was compared with the whole list, attribute by attribute. A cached hash per element made that one number per entry (#68; see Limits and hostile input).

The raw output of this run
Lexbor 3.0.1, html5ever 0.40.1, Parsec fd18b9c; macos aarch64, 12 threads available
MB/s, peak MB size Parsec Lexbor html5ever vs Lexbor
Real pages
wikipedia-html 0.81 MB 568 3.2 297 8.7 97 5.1 1.91x
wikipedia-population 1.39 MB 698 5.6 351 12.8 110 7.5 1.99x
mdn-html 0.19 MB 567 0.7 385 2.0 101 1.0 1.47x
github-rust 0.33 MB 642 1.3 357 3.3 103 1.6 1.80x
bbc-news 0.40 MB 1621 1.6 684 2.6 200 1.3 2.37x
hacker-news 0.04 MB 321 0.1 198 1.5 58 0.4 1.62x
stackoverflow 1.16 MB 676 4.6 348 9.5 100 6.4 1.94x
python-stdtypes 0.77 MB 308 4.6 186 12.4 58 9.5 1.66x
nytimes 1.57 MB 1783 6.3 673 7.3 237 4.3 2.65x
reddit-programming 0.58 MB 1438 2.4 700 3.0 206 1.7 2.05x
ebay 0.53 MB 1130 2.2 535 3.6 180 1.9 2.11x
whatwg-parsing 0.83 MB 407 3.2 238 9.5 91 7.2 1.71x
whatwg-full 15.78 MB 297 94.1 206 195.5 71 162.4 1.44x
all real pages 24.36 MB 370 242 82 1.53x
Generated shop listings
shop 1 MB 1.00 MB 528 3.9 260 12.1 78 8.4 2.03x
shop 10 MB 10.00 MB 532 39.2 261 113.4 78 83.4 2.04x
Hostile inputs
unclosed divs 0.40 MB 131 8.4 5.2 s 16.5 8.8 s 14.9 1705.10x
unclosed tables 0.28 MB 155 2.8 93 16.1 34 7.8 1.66x
nested inline 0.48 MB 147 5.9 101 16.5 34 15.0 1.45x
formatting then paragraphs 0.02 MB 68 0.6 29 2.1 5 1.1 2.33x
distinct formatting per p 0.28 MB 29 21.3 26 43.6 11 38.2 1.11x
misnested a 0.28 MB 61 9.6 39 37.7 20 19.5 1.57x
adoption 0.16 MB 60 3.5 0.6 s 8.7 1.1 s 7.4 240.64x
table foster 0.30 MB 89 5.5 60 17.1 27 16.0 1.48x

The same 13 real pages, each parsed once by Parsec and once by Lexbor before any timing, then each of the 32 selectors from crates/parsec/examples/select.rs run over every document: Parsec’s SelectorList::select against Lexbor’s lxb_selectors_find. A time is the median of 30 runs after one warm-up, for all 13 documents together. html5ever has no selector engine of its own, so it isn’t here.

Lexbor is set up the way its own normal_way.c example does it, with LXB_SELECTORS_OPT_MATCH_FIRST so an element matched by two selectors in a list is counted once, as querySelectorAll counts it. Each selector list is parsed before timing, by both.

Parsec takes 226 ms for all 32 and Lexbor 728, so Parsec is 3.2 times as fast, and ahead on every selector. The closest are body *:last-child, nav ul li a and [class], between 1.1 and 1.2 times. The widest is p:nth-child(2n+1), at 31 times.

Selector Parsec ms Lexbor ms Parsec vs Lexbor Matches
* 5.47 12.39 2.27× 411,995
a 6.00 11.54 1.92× 81,232
div a 8.00 12.19 1.52× 48,669
ul > li 5.78 11.45 1.98× 7,996
li + li 5.83 11.42 1.96× 17,239
li ~ li 6.12 11.47 1.88× 17,306
[href] 7.38 10.29 1.40× 82,212 vs 82,220
a[href^='/'] 7.45 11.67 1.57× 1,396
a[href$='.html'] 7.20 11.77 1.64× 215
a[href*='?'] 8.74 17.59 2.01× 450
[class] 8.28 10.03 1.21× 75,152
img[alt] 5.58 11.21 2.01× 672
div:first-child 5.72 11.43 2.00× 6,002
li:last-child 5.62 11.59 2.06× 4,412
p:nth-child(2n+1) 11.03 339.32 30.77× 23,947
tr:nth-of-type(odd) 6.41 25.05 3.91× 2,681
span:only-child 5.63 11.49 2.04× 9,623
:root > body 5.69 11.45 2.01× 13
div:not([class]) 6.51 11.33 1.74× 3,833
:is(h1, h2, h3) 11.05 16.68 1.51× 615
article:has(img) 5.90 11.46 1.94× 19
meta[name][content] 5.57 11.24 2.02× 143
script:empty 5.62 11.30 2.01× 147
td:nth-last-child(2) 5.67 11.56 2.04× 4,692
nav ul li a 11.60 13.74 1.18× 1,475
div > div > div 5.88 11.36 1.93× 7,755
[data-testid] 6.91 12.98 1.88× 1,079
input[name] 5.88 11.37 1.94× 22
a:first-of-type 6.99 12.48 1.79× 59,159
section h2 + p 6.07 11.57 1.91× 26
li:nth-child(-n+3) 5.79 11.69 2.02× 10,961
body *:last-child 14.56 16.15 1.11× 163,928
all 32 226 728 3.22×

The match counts are shown so a time is never compared across different answers. They agree everywhere except [href], where Lexbor finds eight more: it also matches SVG’s xlink:href. A selector with no namespace prefix matches only attributes in no namespace, as querySelectorAll does in a browser, so Parsec doesn’t.

Before netweir/netweir#324, p:nth-child(2n+1) took Parsec 314 ms, because finding an element’s position meant counting its earlier siblings again for every element. Now the positions under a parent are counted once per query, and the whole battery went from 1.3 to 3.2 times Lexbor’s speed.

To run only this table: cargo run --release --manifest-path bench/Cargo.toml -- selectors. It needs the real pages from bench/fetch-pages.sh.

Bytes to UTF-8 text against Lexbor’s encoding module, run with parsec-web-bench encoding (not part of a full run). Encoding has the table and how to read it. In short: on real pages transcoded to Shift_JIS, windows-1251 and GBK, Parsec decodes 8 to 10 GB/s and Lexbor, decoding and then encoding to UTF-8, 240 to 377 MB/s. On dense text the gap is 1.5 to 3.8 times. Lexbor’s decoders alone, writing code points you’d still convert, beat Parsec on dense GBK.

The same run checks Lexbor’s decoders against the web-platform-tests character pages. They match on EUC-JP, ISO-2022-JP, EUC-KR and Big5. On Shift_JIS they get 5,240 of 7,393 characters right.

The same 13 pages, now as a source of links: every href and src value on them, 83,113 strings, each parsed against its page’s address from bench/pages.txt (none of the pages has a <base href>). Then the 904 inputs of WPT’s urltestdata.json, against their own bases, which are mostly the odd cases. Three parsers:

  • Parsec is parsec-url (URL), Parsec’s own URL parser.
  • Lexbor 3.0 is lxb_url_parse, with lxb_url_parser_clean after each parse, as its header asks.
  • Ada 4.0.0, the C++ parser in Node.js, comes in as a submodule at its release tag and is compiled by the cc crate at -O3 with NDEBUG, as its CMake release build is. Ada’s C API parses the base again on every call that has one, which the other two don’t do, so bench/src/ada.cpp calls its C++ ada::parse with a base already parsed.

Every base is parsed before timing, by each parser. Each URL is built and freed. A time is the median of 30 passes over the whole list, after one warm-up, given as nanoseconds per URL.

List URLs Parsec Lexbor Ada Parsec vs Lexbor Parsec vs Ada
href and src on the 13 pages 83,113 107 ns 243 ns 142 ns 2.28× 1.33×
WPT urltestdata.json inputs 904 124 ns 183 ns 157 ns 1.48× 1.27×

That’s two runs on 18 November 2026, both with the one-minute load under 3; the first gave 104, 239 and 141 ns on the pages, within 3% of these. A third, with the branch merged with main, gave 105, 247 and 148; its full output is below. Parsec is ahead of both on both lists: 2.3 times as fast as Lexbor and a third faster than Ada on real links. Before its own parser, when parsec-url was the url crate, it took 181 ns on the same links, 1.27 times as long as Ada.

The answers are checked as well as the times. On the real links all three parse all 83,113, and Lexbor’s and Ada’s hrefs match Parsec’s on every one. On the WPT inputs, which are mostly the odd cases, Parsec and Ada both parse 634 and agree on every href; Lexbor parses 626, and its results differ from Parsec’s on 16.

The raw output of a third run, on the branch merged with main
Lexbor 3.0.1, html5ever 0.40.1, Ada 4.0.0, Parsec 2f1d5cb; macos aarch64, 12 threads available
URLs, median of 30 passes: ns per URL (URLs that parsed)
URLs Parsec Lexbor Ada vs Lexbor vs Ada
hrefs and srcs on the 13 real pages 83113 105 ( 83113) 247 ( 83113) 148 ( 83113) 2.36x 1.41x
Lexbor disagrees with Parsec on 0
Ada disagrees with Parsec on 0
WPT urltestdata.json inputs 904 133 ( 634) 186 ( 626) 153 ( 634) 1.40x 1.15x
Lexbor disagrees with Parsec on 16
Ada disagrees with Parsec on 0

To run only this table: cargo run --release --manifest-path bench/Cargo.toml -- urls. It needs the real pages and the bench/ada submodule, and a C++20 compiler.

Tokenizing and parsing stylesheets, against Lexbor’s CSS module and Servo’s cssparser 0.38, run with parsec-web-bench css and at the end of a full run. Ten sheets, 1.87 MB: the <style> elements of each real page with more than a kilobyte of them, taken together as one sheet per page (five pages), and the five stylesheets in bench/stylesheets.txt, Bootstrap 5.3.3 plain and minified, Bulma 1.0.2, Font Awesome 6.6.0 and normalize.css 8.0.1, fetched by bench/fetch-pages.sh and checked against their SHA-256.

  • Tokenizing is every token in the sheet, comments skipped: Parsec’s Tokenizer, Lexbor’s lxb_css_syntax_token and lxb_css_syntax_token_consume in a loop (in bench/src/lexbor_css.c, because reading a token’s type needs Lexbor’s struct layout), and cssparser’s next_including_whitespace into every nested block.
  • Parsing is the whole sheet with every block’s contents parsed into declarations and nested rules, all kept until the clock stops. For Parsec that’s parse_stylesheet_deep, which parses each block’s contents as it reaches them. For Lexbor it’s lxb_css_stylesheet_parse, with the parser and its selectors module made once; it also parses each selector and the values of the 105 properties it knows, which is more work than a syntax parse. cssparser builds nothing of its own, so it’s given the least a caller would: StyleSheetParser and RuleBodyParser, keeping each prelude and declaration value as its tokens.

A time is the median of 30 runs after one warm-up; freeing isn’t timed. MB/s is the sheet’s size over that median.

All ten, MB/s Parsec Lexbor cssparser Parsec vs Lexbor Parsec vs cssparser
Tokenizing 389 210 318 1.85× 1.22×
Parsing 211 112 196 1.88× 1.08×

That’s the second of two runs on 18 November 2026, at commit 82fee36, each started with the one-minute load at 2.5; the first gave 370, 214 and 318 MB/s tokenizing and 220, 115 and 190 parsing, so 1.16 times cssparser’s speed. Parsec is ahead of Lexbor on every sheet at both, 1.2 to 2.8 times tokenizing and 1.6 to 2.7 times parsing, and tokenizes faster than cssparser on every sheet. It parses faster than cssparser on every sheet in the first run, by 1.09 to 1.27 times, and on nine of ten in the second; Bulma came out level, 232 to 234, where the first run had 263 to 233.

Until #88 this row was 148 MB/s, three quarters of cssparser’s speed: the parse kept each rule’s block as component values and then walked it again with contents. parse_stylesheet_deep parses each block’s declarations and rules straight from the tokenizer as it reaches them, one pass, and that’s the whole difference.

The raw output of the second run
CSS: 10 stylesheets, 1.87 MB, MB/s (median of 30)
KB Parsec Lexbor cssparser vs L vs c Parsec Lexbor cssparser vs L vs c
tokenize parse
wikipedia-html <style> 21 436 209 346 2.08x 1.26x 205 111 175 1.85x 1.17x
wikipedia-population <style> 32 474 231 381 2.05x 1.24x 242 115 215 2.11x 1.12x
bbc-news <style> 71 409 194 331 2.11x 1.24x 203 105 170 1.93x 1.20x
nytimes <style> 43 393 200 319 1.97x 1.23x 210 103 180 2.03x 1.16x
reddit-programming <style> 284 266 217 233 1.23x 1.14x 171 97 150 1.77x 1.14x
bootstrap.css 281 389 167 334 2.33x 1.17x 215 112 198 1.93x 1.08x
bootstrap-min.css 233 411 231 351 1.78x 1.17x 214 116 193 1.85x 1.11x
bulma.css 763 465 231 365 2.02x 1.27x 232 135 234 1.72x 0.99x
fontawesome.css 133 336 182 244 1.85x 1.38x 183 69 161 2.66x 1.14x
normalize.css 6 809 292 515 2.77x 1.57x 426 192 366 2.21x 1.16x
all stylesheets 1866 389 210 318 1.85x 1.22x 211 112 196 1.88x 1.08x

The same sheets parsed with parse_stylesheet_deep and then every declaration’s value parsed for its property with values::parse_declaration_value, against Lexbor’s lxb_css_stylesheet_parse, which types the 105 properties it knows as it goes. Timed the same way, printed after the table above.

All ten, MB/s Parsec Lexbor Parsec vs Lexbor
Parse, every value typed 145 114 1.26×

Second of two runs on 19 November 2026, each started with the one-minute load under 2.1; the first gave 143 to 115 (1.24×). Parsec is ahead on every sheet in both, from 1.04× (the New York Times’ <style>) to 1.9× (Font Awesome). Before #92 it was 0.70× to 1.17×; CSS values says what changed. Parsec types all 822 properties where Lexbor types 105, and Lexbor also parses selectors.

The raw output of the second run
CSS with typed values, MB/s (median of 30)
KB Parsec Lexbor vs L
wikipedia-html <style> 21 118 113 1.05x
wikipedia-population <style> 32 174 116 1.50x
bbc-news <style> 71 115 109 1.06x
nytimes <style> 43 112 107 1.04x
reddit-programming <style> 284 118 107 1.10x
bootstrap.css 281 135 107 1.26x
bootstrap-min.css 233 125 117 1.07x
bulma.css 763 183 136 1.34x
fontawesome.css 133 134 70 1.90x
normalize.css 6 302 178 1.69x
all stylesheets 1866 145 114 1.26x
(33134 declaration values parsed and typed by Parsec)

The same run then styles each of the 13 real pages: parsed, then every element’s computed values from the HTML user agent stylesheet and the page’s own <style> elements (<link>ed sheets aren’t fetched), median of five. Lexbor has no computed values to compare with. All 13 take 2,311 ms, the HTML spec’s 337,200 elements 1,594 of them; reddit’s 284 KB of <style> costs 191 ms for 1,280 elements. Cascade has the table.

To run only this table: cargo run --release --manifest-path bench/Cargo.toml -- css. It needs the real pages and the stylesheets from bench/fetch-pages.sh.

Parsing JavaScript to a syntax tree, against oxc_parser 0.157.0 and swc_ecma_parser 47.0.0, run with parsec-web-bench js. The corpus is 11.6 MB: the three bundles pinned in bench/scripts.txt (react-dom 19.2.0’s production client, three.js 0.181.0 as a module, and typescript.js 5.9.3), fetched from jsDelivr by bench/fetch-pages.sh and checked against their SHA-256, and the inline <script> elements of each real page, parsed one by one.

  • Parsec is parsec_js::parse, which keeps the comments beside the tree.
  • oxc is Parser::new(&allocator, src, SourceType::cjs()) (mjs() for the module) and .parse(), with a fresh Allocator each time, kept with the program in it. It keeps comments too.
  • swc is Parser::new(Syntax::Es(..), StringInput, None) and parse_script or parse_module. With no comment store it keeps none, the least it can be asked to do.

A time is the median of at least five runs after one warm-up, more for small sources, up to half a second’s worth; freeing isn’t timed. Peak memory is counted as for the HTML tables. An inline script any of the three rejects would be left out; none was.

Parsec MB/s oxc MB/s swc MB/s Parsec peak oxc peak swc peak Parsec vs oxc Parsec vs swc
react-dom 19.2.0, 0.54 MB 334 288 140 2.9 MB 4.2 MB 5.1 MB 1.16× 2.39×
three.js 0.181.0, 0.63 MB 389 391 187 3.3 MB 4.2 MB 5.4 MB 0.99× 2.08×
typescript.js 5.9.3, 9.11 MB 370 355 142 44.4 MB 67.1 MB 90.5 MB 1.04× 2.61×
Inline scripts, 1.30 MB 221 to 652 253 to 675 87 to 200 0.79× to 1.09× 2.33× to 3.26×
All, 11.58 MB 380 363 147 1.05× 2.59×

Parsec is ahead of swc on every source and holds less memory than either on every one. It’s ahead of oxc on react-dom, typescript.js and the larger inline scripts of nytimes and ebay, level on three.js, and behind on the small inline scripts: 0.79× on mdn’s 0.3 KB, 0.81× on python-stdtypes and 0.84× on whatwg’s 0.2 KB, where each parse’s fixed cost counts most; that’s what’s left of #190. #215, #236, #239 and #249 took it from 0.57× oxc’s speed to 1.05×. On 28 November 2026, the median of three runs interleaved with three of main before #249, with the one-minute load at 5 to 10 (higher than the 3 these tables aim for); the totals of the three were 380, 380 and 383 MB/s.

Every tree is the one acorn gives: crates/parsec-js/scripts/compare-acorn.sh --bench parses all 107 sources with acorn 8.19.0 and with Parsec and finds no difference.

The raw output
JavaScript: oxc_parser 0.157.0, swc_ecma_parser 47.0.0. MB/s and peak MB, median of at least 5 runs
KB Parsec oxc swc vs oxc vs swc
react-dom-19.2.0.js 536.0 340 2.9 291 4.2 142 5.1 1.17x 2.40x
three-0.181.0.mjs 626.2 391 3.3 393 4.2 188 5.4 0.99x 2.08x
typescript-5.9.3.js 9112.6 372 44.4 346 67.1 142 90.5 1.08x 2.62x
wikipedia-html <script> 8.1 656 0.1 675 0.1 202 0.1 0.97x 3.25x
wikipedia-population <script> 7.6 634 0.1 653 0.1 197 0.1 0.97x 3.23x
mdn-html <script> 0.3 327 0.0 431 0.0 146 0.0 0.76x 2.24x
bbc-news <script> 3.5 392 0.0 425 0.1 142 0.0 0.92x 2.76x
stackoverflow <script> 6.9 518 0.1 563 0.2 189 0.1 0.92x 2.74x
python-stdtypes <script> 1.3 386 0.0 484 0.0 147 0.0 0.80x 2.63x
nytimes <script> 982.7 506 6.0 454 6.4 180 6.9 1.11x 2.82x
reddit-programming <script> 40.2 221 0.6 256 1.1 88 0.8 0.86x 2.52x
ebay <script> 252.4 624 2.0 601 2.4 195 1.9 1.04x 3.20x
whatwg-parsing <script> 0.2 324 0.0 388 0.0 139 0.0 0.83x 2.33x
whatwg-full <script> 0.2 324 0.0 388 0.0 139 0.0 0.83x 2.33x
all 11578.2 383 44.4 356 67.1 147 90.5 1.08x 2.60x
("vs" is Parsec's speed over the other's; 0 inline scripts left out because a parser rejects them)

Only the tokens, with parsec-web-bench js-lex: parsec-js’s Lexer against the lexers inside oxc_parser 0.157.0 and swc_ecma_parser 47.0.0, on the same 11.6 MB, the three bundles and each page’s inline scripts.

A lexer can’t tell on its own whether a / divides or starts a regular expression, or whether a } goes back into a template. Parsec’s is told, with a Goal; oxc’s and swc’s ask their parser, and that part isn’t public. So before anything is timed, each regular expression, and each template with a ${, is written over as a string of the same length in bytes, "xx…x", found from Parsec’s own syntax tree. oxc’s lexer bench cleans its corpus the same way. That’s 0.4% of the corpus. What’s left has one reading: every / divides and every } is a punctuator, which is the goal Parsec’s parser would choose, so Parsec’s lexer is given Goal::Div for every token. Templates without a ${ are left alone; all three lex them whole.

  • Parsec is Lexer::new(src, SourceType) and next_token(Goal::Div) to the end, counting all but comments.
  • oxc is lexer::Lexer::new_for_benchmarks with NoTokensLexerConfig, made public by oxc_parser’s benchmarking feature, then first_token and next_token_for_benchmarks to the end, with a fresh Allocator each time. It skips comments itself.
  • swc is Lexer::new(Syntax::Es(..), EsVersion::latest(), StringInput, None), read as an iterator. With no comment store it keeps no comments.

Before the clock starts, all three are checked against each other on every piece: the same tokens at the same byte spans, and no errors. Two splits are joined first, where each parser would join them. oxc reads every > on its own, so that TypeScript’s a<b<c>> can close twice, and its parser puts >=, >>, >>=, >>> and >>>= back together; swc reads ?. as ? then .. Neither is joined across a space. After that the three agree on every token of all 107 sources, so the tolerance is none. Tokens a second counts tokens as Parsec splits them, the same count for all three.

A time is the median of at least five runs after one warm-up, as for parsing.

Parsec MB/s oxc MB/s swc MB/s Parsec M tokens/s oxc M tokens/s swc M tokens/s Parsec vs oxc Parsec vs swc
react-dom 19.2.0, 82,293 tokens 309 493 287 47.4 75.7 44.0 0.63× 1.08×
three.js 0.181.0, 76,697 tokens 358 579 345 43.8 70.9 42.3 0.62× 1.04×
typescript.js 5.9.3, 1,311,509 tokens 337 547 327 48.4 78.8 47.1 0.61× 1.03×
Inline scripts, 174,951 tokens 278 to 583 490 to 1,561 210 to 422 59.9 to 102.7 98.8 to 226.2 43.0 to 75.7 0.33× to 0.61× 1.19× to 1.75×
All, 1,645,450 tokens 347 568 328 49.3 80.7 46.6 0.61× 1.06×

Parsec’s lexer is ahead of swc’s on every source, by the most on the small inline scripts, and behind oxc’s on every one, as its parser is. On 22 November 2026, at the commit that added the lexer bench, with the one-minute load at 3.2; the run just before it, at 3.5, gave the same totals within 1%.

The raw output
JavaScript lexing: oxc_parser 0.157.0, swc_ecma_parser 47.0.0. MB/s and millions of tokens a second, median of at least 5 runs
KB cleaned tokens Parsec oxc swc vs oxc vs swc
react-dom-19.2.0.js 536.0 0.0% 82293 309 47.4 493 75.7 287 44.0 0.63x 1.08x
three-0.181.0.mjs 626.2 0.3% 76697 358 43.8 579 70.9 345 42.3 0.62x 1.04x
typescript-5.9.3.js 9112.6 0.5% 1311509 337 48.4 547 78.8 327 47.1 0.61x 1.03x
wikipedia-html <script> 8.1 0.9% 1046 522 67.7 1561 202.4 422 54.7 0.33x 1.24x
wikipedia-population <script> 7.6 0.9% 1016 520 69.9 1500 201.5 414 55.7 0.35x 1.25x
mdn-html <script> 0.3 0.0% 77 455 102.7 909 205.3 327 73.9 0.50x 1.39x
bbc-news <script> 3.5 0.0% 754 460 98.3 1057 226.2 334 71.5 0.43x 1.37x
stackoverflow <script> 6.9 1.3% 949 583 79.9 1240 170.0 417 57.1 0.47x 1.40x
python-stdtypes <script> 1.3 0.0% 262 484 99.8 953 196.5 367 75.7 0.51x 1.32x
nytimes <script> 982.7 0.3% 125321 470 59.9 775 98.8 337 43.0 0.61x 1.39x
reddit-programming <script> 40.2 1.6% 11345 278 78.4 490 138.4 210 59.4 0.57x 1.32x
ebay <script> 252.4 0.1% 34115 463 62.6 1190 160.8 389 52.6 0.39x 1.19x
whatwg-parsing <script> 0.2 0.0% 33 486 99.1 970 197.6 278 56.6 0.50x 1.75x
whatwg-full <script> 0.2 0.0% 33 486 99.1 970 197.6 299 60.9 0.50x 1.63x
all 11578.2 0.4% 1645450 347 49.3 568 80.7 328 46.6 0.61x 1.06x
("cleaned" is the share written over as strings; "vs" is Parsec's speed over the other's; 0 inline scripts left out because a parser rejects them)
All three lexers read the same tokens, at the same spans, with no errors, in every piece.

Everything above is one clean page at a time, already decoded. A crawler’s day isn’t like that. It gets 1,000 pages of whatever the web sent: scraps of broken markup, a page in Shift_JIS whose <meta> says UTF-8, and now and then 25 MB of table. The final boss is that day, built from a seed, fed to each parser as bytes, and timed per page with the process’s peak memory. It answers a different question from the tables above: not how fast, but whether anything falls over, and what a whole batch costs.

Seed 20261119. Page i is built from the seed and i alone, so the same seed gives the same bytes, in the same order, for every parser and on every run; the bench prints an FNV-1a fingerprint of every byte so you can check (de2480edafa2baa9 here, with bench/corpus from bench/fetch-pages.sh). The categories are shuffled through the batch by the same seed. Out of 1,000:

Category Pages Bytes What’s in it
Fragments 900 1.4 MB One to six kinds of breakage each, a few hundred bytes.
Real pages 46 33.0 MB The twelve corpus pages under 2 MB, as served, in turn.
Encodings 44 36.6 MB Real pages re-encoded, four of each of eleven quirks.
Giants 10 194.2 MB 10 to 30 MB each, three kinds.

Why that mix: by count, a crawl is mostly small, odd pages, and fragments are where per-page overhead shows. By bytes it’s the giants, 1% of the pages and three quarters of the input, and they’re where memory and slow paths show. Encodings at 4% is more than a modern crawl sees, on purpose, so each quirk gets four pages. The parsing takes about 1.5 s for Parsec and 6 for html5ever, and three runs of every parser took 5 minutes 36 seconds here, 34 seconds of it on the CPU and most of the rest waiting for the load to settle.

Fragments pick from: unclosed tags; misnested ones (<b><i>x</b></i>, <a><div></a>, <p><table><p>, nested <form>s); stray end tags (</p>, </table>, </td>, </br>, </body>); unquoted and duplicate attributes, a=b=c, quotes that don’t match; < in text, <?php ?>, <!x; NUL bytes in text, tag names and attributes; bare &, &amp and &lt3 without semicolons; numeric references out of range or to surrogates, &#0;, &#128;, &#99999999999999999999;, &#x;; long named-reference prefixes (&notit;, &CounterClockwiseContourIntegra, references inside href); table soup with text, a <caption> mid-row; <select>, <svg>, <math> and <foreignObject> mixed up; <template>, including shadowrootmode; runs of formatting tags before paragraphs. One in five starts with an odd doctype (HTML 4.01, <!doctype>, one never closed). One in twenty adds 1,000 to 5,000 levels of nesting, of <div>, <span>, <b>, <a>, <ul><li>, <table><tr><td>, <svg><g> or <i><div>. Two in five end with something left open to the end of the input: a comment, CDATA, <script>, <textarea>, <title>, <style>, <plaintext>, <xmp>, an attribute’s quote, a tag, <!, </, &#x.

Encodings, each with 50 to 300 paragraphs of text in the encoding’s own script added so the decoders do real work (a character the encoding lacks becomes a numeric reference):

  1. Shift_JIS, declared by <meta charset>.
  2. windows-1251, declared.
  3. GBK, declared.
  4. EUC-KR, declared.
  5. UTF-16LE with a BOM, while the page’s <meta> still says UTF-8.
  6. UTF-16BE with a BOM, the same.
  7. A <meta> that lies: says UTF-8, bytes are windows-1251.
  8. A BOM that disagrees: UTF-8 BOM, <meta charset=windows-1251>.
  9. A transport hint: EUC-KR bytes, charset=euc-kr as from an HTTP header, and a <meta> saying ISO-8859-1.
  10. UTF-8 with Japanese, Russian, Chinese and Korean text and no declaration at all.
  11. UTF-8 with invalid bytes every few kilobytes: FF, overlong C0 AF, a surrogate ED A0 80, a cut-off E2 82, a lone 80, F4 90 80 80 past U+10FFFF.

Giants: real pages run together (whole documents, doctypes and all, the 15.8 MB HTML Standard among them); one huge table of rows where every tenth row leaves its cells open; and one paragraph that’s a single text node of character references, named, numeric, unterminated and invalid, with words between.

  • Parsec: parsec_encoding::parse_bytes, with Options::transport set when the page has a transport hint. That’s the browser’s algorithm: BOM, transport, prescan, UTF-8 detection, windows-1252, and a second parse if a later <meta> changes the encoding.
  • Lexbor 3.0.1, with its own pieces: lxb_encoding_bom_sniff, then lxb_encoding_data_by_pre_name for the transport label, then lxb_html_encoding_prescan over the first 1,024 bytes with lxb_encoding_data_prescan_validate, then windows-1252, since Lexbor has no detector to guess UTF-8. Anything not UTF-8 is decoded by its encoding module to UTF-8 (lxb_encoding_decode_* and lxb_encoding_encode_utf_8), and the result goes to lxb_html_document_parse. UTF-8, and pure ASCII in an encoding that keeps ASCII, skip the decode and go straight in, as a caller would do. So invalid UTF-8 reaches Lexbor’s parser as it is, and Lexbor never parses again for a late <meta>.
  • html5ever 0.40.1 takes text, not bytes, so encoding_rs decodes for it with Parsec’s sniffing (parsec_encoding::sniff), without the second parse. That’s labelled html5ever below, but its encoding handling is encoding_rs’s.

The bench re-runs itself three levels deep. For each parser it starts a process that builds the pages and writes them, one at a time, to a worker of that parser over a pipe. The worker reads each page into one buffer it keeps, times bytes to finished document, then counts the elements and frees the document outside the time. Its peak is getrusage(RUSAGE_CHILDREN)’s ru_maxrss, read by the process in the middle, whose only children are that parser’s workers (bytes on macOS, kilobytes on Linux, both handled). The “no parser” row is a worker that reads the pages and does nothing else: 32 MB, the buffer for the biggest page.

A page still parsing after 10 seconds is a timeout. A watchdog thread in the worker ends it, and a new worker carries on from the next page, as it does after a crash, a panic or an abort, so one bad page costs one page. A timeout counts as 10 s in the totals. A document with fewer than three elements (html, head and body are always there) counts as no document.

Each parser’s element count, walked in tree order from the document without going into template contents or shadow roots, is compared with Parsec’s on every page. A <template shadowrootmode> is a shadow root in Parsec, as the spec now has it, and an element in Lexbor 3.0.1 and html5ever, so Parsec counts it as the element.

Each of the three runs per parser waits for the one-minute load average to fall below 2 first, for up to two hours in all, and a different parser goes first each run. Numbers are medians of the three runs: of the total, of the slowest page, of the peak and of each category’s time.

20 November 2026, the same M2 Max, Parsec at 4d6fe82 (after #124), load 1.58 to 1.85 at the start of every run.

Seconds per 1,000 pages Slowest page Peak RSS Crashes Timeouts Refused No document
Parsec 1.02 0.163 s 516 MB 0 0 0 0
Lexbor 3.0.1 1.94 0.247 s 952 MB 0 0 0 0
html5ever 0.40.1 5.99 0.804 s 708 MB 0 0 0 0
No parser 32 MB
Pages MB Parsec Lexbor html5ever
Fragments 900 1.4 0.049 (0.014) 0.407 (0.062) 0.752 (0.107)
Real pages 46 33.0 0.057 (0.003) 0.132 (0.008) 0.298 (0.014)
Encodings 44 36.6 0.063 (0.003) 0.179 (0.011) 0.308 (0.014)
Giants 10 194.2 0.854 (0.163) 1.221 (0.247) 4.636 (0.804)
Real pages run together 4 0.264 0.373 1.047
One huge table 3 0.363 0.556 1.799
One text node of references 3 0.211 0.280 1.790

Parsec is ahead in every category and on every kind of giant. The reference-heavy text nodes were the one shape Lexbor won, twice as fast as Parsec, until #124: reference names now come from a hash table built at compile time, and a stretch of text reaches the tree builder in one run instead of a new one at every reference. Those three pages went from 0.58 s to 0.21, and the slowest page from 0.258 s to 0.163.

Lexbor 3.0.1, html5ever 0.40.1, Ada 4.0.0, Parsec 4d6fe82; macos aarch64, 12 threads available
The final boss: 1000 pages, seed 20261119, 3 runs per parser
fragments 900 pages 1.4 MB
real pages 46 pages 33.0 MB
encodings 44 pages 36.6 MB
giants 10 pages 194.2 MB
fingerprint of every byte, in order: de2480edafa2baa9
run 1 Parsec load 1.70 at start, 1.0 s
run 1 Lexbor load 1.70 at start, 2.0 s
run 1 html5ever load 1.58 at start, 6.0 s
run 1 no parser load 1.82 at start, 0.0 s
run 2 Lexbor load 1.82 at start, 1.9 s
run 2 html5ever load 1.82 at start, 6.0 s
run 2 no parser load 1.85 at start, 0.0 s
run 2 Parsec load 1.85 at start, 1.0 s
run 3 html5ever load 1.85 at start, 6.0 s
run 3 no parser load 1.79 at start, 0.0 s
run 3 Parsec load 1.79 at start, 1.0 s
run 3 Lexbor load 1.79 at start, 1.9 s
median s/1,000 pages slowest page peak RSS crashes timeouts refused no document
Parsec 1.02 0.163 s 516 MB 0 0 0 0
Lexbor 1.94 0.247 s 952 MB 0 0 0 0
html5ever 5.99 0.804 s 708 MB 0 0 0 0
no parser - - 32 MB - - - -
Per category, median seconds for the pages in it (slowest page in brackets)
pages MB Parsec Lexbor html5ever
fragments 900 1.4 0.049 s ( 0.014 s) 0.407 s ( 0.062 s) 0.752 s ( 0.107 s)
real pages 46 33.0 0.057 s ( 0.003 s) 0.132 s ( 0.008 s) 0.298 s ( 0.014 s)
encodings 44 36.6 0.063 s ( 0.003 s) 0.179 s ( 0.011 s) 0.308 s ( 0.014 s)
giants 10 194.2 0.854 s ( 0.163 s) 1.221 s ( 0.247 s) 4.636 s ( 0.804 s)
real pages run together 4 0.264 s 0.373 s 1.047 s
one huge table 3 0.363 s 0.556 s 1.799 s
one text node of references 3 0.211 s 0.280 s 1.790 s
Parsec's slowest page: 581 (giants, one huge table, 27.6 MB), 0.163 s
Lexbor's slowest page: 581 (giants, one huge table, 27.6 MB), 0.247 s
html5ever's slowest page: 945 (giants, one text node of references, 21.8 MB), 0.802 s
Pages where Lexbor's element count differs from Parsec's: 0 (fragments 0, real 0, encodings 0, giants 0)
Pages where html5ever's element count differs from Parsec's: 0 (fragments 0, real 0, encodings 0, giants 0)
Load average at the start of each run, by parser: 1.70, 1.85, 1.79, 1.70, 1.82, 1.79, 1.58, 1.82, 1.85, 1.82, 1.85, 1.79
No crashes or timeouts.

19 November 2026, the same M2 Max, Parsec at ff26ac9, load 1.68 to 1.98 at the start of every run.

Seconds per 1,000 pages Slowest page Peak RSS Crashes Timeouts Refused No document
Parsec 1.49 0.258 s 512 MB 0 0 0 0
Lexbor 3.0.1 1.93 0.249 s 1,044 MB 0 0 0 0
html5ever 0.40.1 5.99 0.811 s 673 MB 0 0 0 0
No parser 32 MB

Per category, the seconds for all the pages in it, slowest page in brackets:

Pages MB Parsec Lexbor html5ever
Fragments 900 1.4 0.048 (0.013) 0.406 (0.060) 0.754 (0.114)
Real pages 46 33.0 0.059 (0.003) 0.134 (0.009) 0.293 (0.015)
Encodings 44 36.6 0.064 (0.003) 0.178 (0.011) 0.306 (0.015)
Giants 10 194.2 1.317 (0.258) 1.214 (0.249) 4.631 (0.811)
Real pages run together 4 0.257 0.365 1.041
One huge table 3 0.466 0.557 1.793
One text node of references 3 0.580 0.278 1.809

What it shows:

  • Nothing fell over. No crash, panic, abort or timeout for any of the three, and every page gave each of them a document. On all 1,000 pages the three element counts agree.
  • Small pages. Lexbor takes 0.45 ms a fragment and Parsec 53 µs, 8.5 times less; html5ever takes 0.84 ms. On fragments this small that’s mostly the cost of setting up a document, which Lexbor does with memory pools allocated up front.
  • Real and re-encoded pages. Parsec is 2.3 times as fast as Lexbor on the real pages (560 MB/s to 246) and 2.8 times on the re-encoded ones (572 to 206), where Lexbor’s decode to code points and back to UTF-8 is part of its time.
  • Giants: Lexbor’s, then. Over the ten, Lexbor was 8% faster, and the reason was the three reference-heavy text nodes, where it was 2.1 times as fast as Parsec. Parsec was ahead on the run-together pages (1.42 times) and the table (1.20). #124 fixed the text-node case; see above.
  • Memory. Parsec’s peak is under half of Lexbor’s and three quarters of html5ever’s. Every peak includes the harness’s 32 MB.

A second set of three runs, later the same day with Parsec at 52cd8fa (no parser change between the two), load 1.75 to 1.90, came out within 2% on every time: 1.48, 1.90 and 5.90 seconds per 1,000 pages, giants 1.305, 1.195 and 4.559 s, the reference-heavy text nodes 0.577 s for Parsec and 0.281 for Lexbor. Peaks move more between runs: Parsec 512 MB both times, Lexbor 1,044 then 1,113 MB, html5ever 673 then 706.

The first set of three:

Lexbor 3.0.1, html5ever 0.40.1, Ada 4.0.0, Parsec ff26ac9; macos aarch64, 12 threads available
The final boss: 1000 pages, seed 20261119, 3 runs per parser
fragments 900 pages 1.4 MB
real pages 46 pages 33.0 MB
encodings 44 pages 36.6 MB
giants 10 pages 194.2 MB
fingerprint of every byte, in order: de2480edafa2baa9
run 1 Parsec load 1.98 at start, 1.5 s
run 1 Lexbor load 1.98 at start, 1.9 s
run 1 html5ever load 1.98 at start, 6.0 s
run 1 no parser load 1.68 at start, 0.0 s
run 2 Lexbor load 1.68 at start, 1.9 s
run 2 html5ever load 1.68 at start, 6.0 s
run 2 no parser load 1.94 at start, 0.0 s
run 2 Parsec load 1.94 at start, 1.5 s
run 3 html5ever load 1.94 at start, 6.0 s
run 3 no parser load 1.87 at start, 0.0 s
run 3 Parsec load 1.87 at start, 1.5 s
run 3 Lexbor load 1.87 at start, 1.9 s
median s/1,000 pages slowest page peak RSS crashes timeouts refused no document
Parsec 1.49 0.258 s 512 MB 0 0 0 0
Lexbor 1.93 0.249 s 1044 MB 0 0 0 0
html5ever 5.99 0.811 s 673 MB 0 0 0 0
no parser - - 32 MB - - - -
Per category, median seconds for the pages in it (slowest page in brackets)
pages MB Parsec Lexbor html5ever
fragments 900 1.4 0.048 s ( 0.013 s) 0.406 s ( 0.060 s) 0.754 s ( 0.114 s)
real pages 46 33.0 0.059 s ( 0.003 s) 0.134 s ( 0.009 s) 0.293 s ( 0.015 s)
encodings 44 36.6 0.064 s ( 0.003 s) 0.178 s ( 0.011 s) 0.306 s ( 0.015 s)
giants 10 194.2 1.317 s ( 0.258 s) 1.214 s ( 0.249 s) 4.631 s ( 0.811 s)
real pages run together 4 0.257 s 0.365 s 1.041 s
one huge table 3 0.466 s 0.557 s 1.793 s
one text node of references 3 0.580 s 0.278 s 1.809 s
Parsec's slowest page: 945 (giants, one text node of references, 21.8 MB), 0.258 s
Lexbor's slowest page: 581 (giants, one huge table, 27.6 MB), 0.249 s
html5ever's slowest page: 945 (giants, one text node of references, 21.8 MB), 0.811 s
Pages where Lexbor's element count differs from Parsec's: 0 (fragments 0, real 0, encodings 0, giants 0)
Pages where html5ever's element count differs from Parsec's: 0 (fragments 0, real 0, encodings 0, giants 0)
Load average at the start of each run: 1.98, 1.94, 1.87, 1.98, 1.68, 1.87, 1.98, 1.68, 1.94, 1.68, 1.94, 1.87
No crashes or timeouts.

The second:

Lexbor 3.0.1, html5ever 0.40.1, Ada 4.0.0, Parsec 52cd8fa; macos aarch64, 12 threads available
The final boss: 1000 pages, seed 20261119, 3 runs per parser
fragments 900 pages 1.4 MB
real pages 46 pages 33.0 MB
encodings 44 pages 36.6 MB
giants 10 pages 194.2 MB
fingerprint of every byte, in order: de2480edafa2baa9
run 1 Parsec load 1.90 at start, 1.5 s
run 1 Lexbor load 1.90 at start, 1.9 s
run 1 html5ever load 1.83 at start, 5.9 s
run 1 no parser load 1.76 at start, 0.0 s
run 2 Lexbor load 1.76 at start, 1.9 s
run 2 html5ever load 1.76 at start, 5.9 s
run 2 no parser load 1.80 at start, 0.0 s
run 2 Parsec load 1.80 at start, 1.5 s
run 3 html5ever load 1.80 at start, 5.9 s
run 3 no parser load 1.75 at start, 0.0 s
run 3 Parsec load 1.75 at start, 1.5 s
run 3 Lexbor load 1.75 at start, 1.9 s
median s/1,000 pages slowest page peak RSS crashes timeouts refused no document
Parsec 1.48 0.258 s 512 MB 0 0 0 0
Lexbor 1.90 0.241 s 1113 MB 0 0 0 0
html5ever 5.90 0.799 s 706 MB 0 0 0 0
no parser - - 32 MB - - - -
Per category, median seconds for the pages in it (slowest page in brackets)
pages MB Parsec Lexbor html5ever
fragments 900 1.4 0.049 s ( 0.014 s) 0.401 s ( 0.060 s) 0.757 s ( 0.109 s)
real pages 46 33.0 0.059 s ( 0.003 s) 0.131 s ( 0.008 s) 0.292 s ( 0.015 s)
encodings 44 36.6 0.066 s ( 0.003 s) 0.175 s ( 0.010 s) 0.300 s ( 0.014 s)
giants 10 194.2 1.305 s ( 0.258 s) 1.195 s ( 0.241 s) 4.559 s ( 0.799 s)
real pages run together 4 0.258 s 0.380 s 1.008 s
one huge table 3 0.460 s 0.538 s 1.739 s
one text node of references 3 0.577 s 0.281 s 1.781 s
Parsec's slowest page: 945 (giants, one text node of references, 21.8 MB), 0.258 s
Lexbor's slowest page: 581 (giants, one huge table, 27.6 MB), 0.241 s
html5ever's slowest page: 945 (giants, one text node of references, 21.8 MB), 0.799 s
Pages where Lexbor's element count differs from Parsec's: 0 (fragments 0, real 0, encodings 0, giants 0)
Pages where html5ever's element count differs from Parsec's: 0 (fragments 0, real 0, encodings 0, giants 0)
Load average at the start of each run, by parser: 1.90, 1.80, 1.75, 1.90, 1.76, 1.75, 1.83, 1.76, 1.80, 1.76, 1.80, 1.75
No crashes or timeouts.

To run it: cargo run --release --manifest-path bench/Cargo.toml -- boss after bench/fetch-pages.sh. Without bench/corpus it still runs, with generated shop listings in place of the real pages, and says so. --runs, --pages, --seed and --tools parsec,lexbor,html5ever,none change the batch, --now skips waiting for a quiet machine, and boss-page N prints page N’s bytes, to look into one.

In CI, the bench job runs boss --smoke: 300 pages, giants capped at 2 MB, Parsec only, once, and it fails on any crash, timeout, refused page or page without a document. It’s a robustness check, not a speed gate.

Terminal window
git clone --recurse-submodules https://github.com/parsec-html/parsec
cd parsec
bench/fetch-pages.sh
cargo run --release --manifest-path bench/Cargo.toml

You need CMake and a C compiler for Lexbor, and a C++20 compiler for Ada. bench/fetch-pages.sh fetches the stylesheets for the CSS table too. Name pages to run only those, by any part of their name: cargo run --release --manifest-path bench/Cargo.toml -- wikipedia "shop 1 MB". Run it on a quiet machine: a build or a browser in the background moves these numbers by a fifth or more.

The table’s first line names the versions and the machine. bench/fetch-pages.sh --print prints the hashes of what it downloaded, for adding a page to bench/pages.txt.

Before bench/, the only number was Netweir’s bench/parse.py: parse a generated shop page from Python and pull out every price, title and link, against selectolax (Lexbor inside). It reports 3.0 ms against 5.7 ms at 1 MB and 31 ms against 64 ms at 10 MB. That includes Python and the queries, and the two libraries do the queries differently, so it’s a scraper’s number, not a parser’s.

crates/parsec/examples has four small programs. Run them from the repository root in release mode (the workspace’s release profile uses thin LTO and one codegen unit):

Command What it times
cargo run --release --example parse FILE parse(&html, false) on the file, 300 times; prints the best time and the node count. The file is read as UTF-8 and the program panics if it isn’t.
cargo run --release --example tokenize FILE preprocess plus the tokenizer alone with a counting sink, 300 times; prints the best time and a count of tags, attributes and text bytes. Also UTF-8 only.
cargo run --release --example select DIR [ROUNDS] Parses every .html file in DIR (decoded lossily as UTF-8), moves template contents into the tree, then runs a battery of 32 selectors over every document; prints the best of ROUNDS rounds (5 by default) and the total number of matches.
cargo run --release --example hostile The eight hostile inputs described in Limits and hostile input; prints size, time and node count for each.

For example:

Terminal window
curl -sL https://html.spec.whatwg.org/ -o /tmp/spec.html
cargo run --release --example parse /tmp/spec.html

The times exclude reading the file. They’re best-of-N, which shows what the code can do on a warm cache rather than what a cold first parse costs. If you compare against another parser, give it the same bytes, the same number of runs, and the same machine, and include the cost of decoding if the other parser decodes for you.