---
title: "Performance"
url: https://recursiveai.org/onehtml/go/docs/performance/
description: "Parse and select measured against x/net/html and cascadia, and the cascade, accessibility tree, checker and rewrite against floors."
version: "1.1.1"
source: https://github.com/recursive-ai-oss/onehtml-go/blob/b6b36a3de36130cf715d83198af600c71d30c3f2/docs/performance.md
---

# Performance

One machine, one day, indicative of relative speed rather than a promise: AMD
Ryzen 9 7950X3D (16 cores, 32 threads), Linux 7.0, Go 1.26.8, 2026-12-01, run
alone on the machine (load average 1.3 before, 1.0 to 2.1 during, 1.6 after),
GOMAXPROCS 32. Each figure is the median of three runs of `go test -bench
-benchmem -count 3`. The corpus is six generated pages in `bench/testdata`
([`bench/README.md`](https://github.com/recursive-ai-oss/onehtml-go/blob/b6b36a3de36130cf715d83198af600c71d30c3f2/bench/README.md)). Before any row counts, a test builds both libraries' trees
(or match lists) for every page and requires them to be identical; they are.

**Parse**, `ParseBytes` against x/net/html (v0.38.0, the faster of the two
versions measured; v0.63.0 is slower still), scripting off in both:

| Page | Size | onehtml MB/s | x/net/html MB/s | Speed-up | onehtml B/op, allocs | x/net/html B/op, allocs |
|---|---:|---:|---:|---:|---:|---:|
| article, small | 16 KB | 156 | 102 | 1.5x | 121 KB, 80 | 157 KB, 1,910 |
| article, medium | 165 KB | 147 | 83 | 1.8x | 1.29 MB, 372 | 1.77 MB, 22,196 |
| article, large | 978 KB | 164 | 85 | 1.9x | 8.6 MB, 1,889 | 10.6 MB, 132,446 |
| product listing | 192 KB | 178 | 109 | 1.6x | 1.80 MB, 78 | 1.62 MB, 25,482 |
| reference page | 165 KB | 145 | 92 | 1.6x | 1.17 MB, 526 | 1.70 MB, 19,821 |
| legacy markup | 224 KB | 104 | 92 | 1.1x | 2.16 MB, 703 | 2.35 MB, 29,426 |

onehtml also keeps the original bytes, the byte range of every node and
attribute, and the parse errors, which x/net/html does not.

**Select**, twenty typical selectors (types, ids, classes, attributes,
combinators, `:nth-child`, `:not`, `:has`), compiled and matched, against
cascadia v1.3.3 on x/net/html trees:

| Page | Compile and match | | Match only | |
|---|---:|---:|---:|---:|
| | onehtml | cascadia | onehtml | cascadia |
| article, medium | 1.35 ms | 2.18 ms | 1.39 ms | 2.16 ms |
| product listing | 0.61 ms | 0.99 ms | 0.64 ms | 0.98 ms |
| reference page | 1.48 ms | 2.33 ms | 1.51 ms | 2.34 ms |

One selector at a time, onehtml is faster on seventeen of twenty and level on
two (`#s17`, `.sec`); `section:has(table)` is 20% slower.

**Rows without a Go competitor**, against floors, single goroutine, on the
medium article page (6,330 elements) unless stated:

| Row | Result | Floor |
|---|---:|---:|
| Cascade: style every element (sheets parsed, three properties read each) | 609,000 elements/s | 300,000 |
| Accessibility tree, `accessibility.Tree` (includes the cascade) | 251,000 elements/s | 50,000 |
| Full check, `validation.Check`, every rule | 76,000 elements/s | 25,000 |
| `Rewrite` of three edits, verified by re-parsing | 70 MB/s (65 MB/s on the 978 KB page) | 20 MB/s |
| `Restyle` after a one-class edit, 7,005-element page | 13 µs (a full restyle: 9.4 ms) | 1 ms |
