Skip to content

Speed up normalizespaceFunc - #191

Merged
zhengchun merged 1 commit into
antchfx:masterfrom
ShoshinNikita:speed-up-normalize-space
Nov 12, 2026
Merged

zhengchun merged 1 commit into
antchfx:masterfrom
ShoshinNikita:speed-up-normalize-space

Conversation

@ShoshinNikita

Copy link
Copy Markdown
Contributor
  • Improve performance of normalizespaceFunc by 50%
  • Add tests for normalizespaceFunc

Benchmark results:

goos: linux
goarch: amd64
pkg: github.com/antchfx/xpath
cpu: 13th Gen Intel(R) Core(TM) i9-13900HX
                      │     old     │                new                 │
                      │   sec/op    │   sec/op     vs base               │
NormalizeSpaceFunc-32   354.0n ± 6%   175.5n ± 2%  -50.42% (p=0.001 n=7)

                      │    old     │                new                │
                      │    B/op    │    B/op     vs base               │
NormalizeSpaceFunc-32   320.0 ± 0%   112.0 ± 0%  -65.00% (p=0.001 n=7)

                      │    old     │                new                │
                      │ allocs/op  │ allocs/op   vs base               │
NormalizeSpaceFunc-32   5.000 ± 0%   4.000 ± 0%  -20.00% (p=0.001 n=7)

- Improve performance of `normalizespaceFunc` by 50%
- Add tests for `normalizespaceFunc`

Benchmark results:

```
goos: linux
goarch: amd64
pkg: github.com/antchfx/xpath
cpu: 13th Gen Intel(R) Core(TM) i9-13900HX
                      │     old     │                new                 │
                      │   sec/op    │   sec/op     vs base               │
NormalizeSpaceFunc-32   354.0n ± 6%   175.5n ± 2%  -50.42% (p=0.001 n=7)

                      │    old     │                new                │
                      │    B/op    │    B/op     vs base               │
NormalizeSpaceFunc-32   320.0 ± 0%   112.0 ± 0%  -65.00% (p=0.001 n=7)

                      │    old     │                new                │
                      │ allocs/op  │ allocs/op   vs base               │
NormalizeSpaceFunc-32   5.000 ± 0%   4.000 ± 0%  -20.00% (p=0.001 n=7)
```
@zhengchun
zhengchun merged commit f4198ff into antchfx:master Nov 12, 2026
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.

2 participants