Commit 855c51d
committed
Optimize IOSource#read_until method
## Why?
For PRE_DEFINED_TERM_PATTERNS terms, encode() is not required.
## Benchmark
```
RUBYLIB= BUNDLER_ORIG_RUBYLIB= /Users/naitoh/.rbenv/versions/3.3.4/bin/ruby -v -S benchmark-driver /Users/naitoh/ghq/github.com/naitoh/rexml/benchmark/parse.yaml
ruby 3.3.4 (2024-07-09 revision be1089c8ec) [arm64-darwin22]
Calculating -------------------------------------
before after before(YJIT) after(YJIT)
dom 16.804 18.277 32.719 32.217 i/s - 100.000 times in 5.951028s 5.471237s 3.056310s 3.103960s
sax 25.975 26.537 45.543 49.366 i/s - 100.000 times in 3.849903s 3.768331s 2.195731s 2.025693s
pull 29.198 30.201 54.224 57.690 i/s - 100.000 times in 3.424872s 3.311141s 1.844205s 1.733406s
stream 29.091 28.778 52.944 54.882 i/s - 100.000 times in 3.437460s 3.474841s 1.888798s 1.822077s
Comparison:
dom
before(YJIT): 32.7 i/s
after(YJIT): 32.2 i/s - 1.02x slower
after: 18.3 i/s - 1.79x slower
before: 16.8 i/s - 1.95x slower
sax
after(YJIT): 49.4 i/s
before(YJIT): 45.5 i/s - 1.08x slower
after: 26.5 i/s - 1.86x slower
before: 26.0 i/s - 1.90x slower
pull
after(YJIT): 57.7 i/s
before(YJIT): 54.2 i/s - 1.06x slower
after: 30.2 i/s - 1.91x slower
before: 29.2 i/s - 1.98x slower
stream
after(YJIT): 54.9 i/s
before(YJIT): 52.9 i/s - 1.04x slower
before: 29.1 i/s - 1.89x slower
after: 28.8 i/s - 1.91x slower
```
- YJIT=ON : 1.02x - 1.08x faster
- YJIT=OFF : 0.98x - 1.08x faster1 parent 622011f commit 855c51d
1 file changed
+5
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
229 | | - | |
230 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
231 | 234 | | |
232 | 235 | | |
233 | 236 | | |
| |||
0 commit comments