Commit e73a154
authored
- before: #106
## Why?
Because they are identical.
https://github.com/ruby/strscan/blob/d31274f41b7c1e28f23d58cf7bfea03baa818cb7/ext/jruby/org/jruby/ext/strscan/RubyStringScanner.java#L267-L268
https://github.com/ruby/strscan/blob/d31274f41b7c1e28f23d58cf7bfea03baa818cb7/ext/jruby/org/jruby/ext/strscan/RubyStringScanner.java#L359-L361
## Benchmark
It shows String as a pattern is 2.33x faster than Regexp as a pattern.
```
$ benchmark-driver benchmark/check_until.yaml
Warming up --------------------------------------
regexp 7.421M i/s - 7.378M times in 0.994235s (134.75ns/i)
regexp_var 7.302M i/s - 7.307M times in 1.000706s (136.95ns/i)
string 12.715M i/s - 12.707M times in 0.999388s (78.65ns/i)
string_var 13.575M i/s - 13.533M times in 0.996914s (73.66ns/i)
Calculating -------------------------------------
regexp 8.287M i/s - 22.263M times in 2.686415s (120.67ns/i)
regexp_var 10.180M i/s - 21.905M times in 2.151779s (98.23ns/i)
string 20.148M i/s - 38.144M times in 1.893226s (49.63ns/i)
string_var 23.695M i/s - 40.726M times in 1.718753s (42.20ns/i)
Comparison:
string_var: 23694846.7 i/s
string: 20147598.6 i/s - 1.18x slower
regexp_var: 10180018.3 i/s - 2.33x slower
regexp: 8287384.8 i/s - 2.86x slower
```
1 parent ff2d7af commit e73a154
1 file changed
+5
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | 266 | | |
271 | 267 | | |
272 | 268 | | |
273 | 269 | | |
274 | 270 | | |
275 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
276 | 275 | | |
277 | 276 | | |
278 | 277 | | |
279 | | - | |
280 | 278 | | |
281 | 279 | | |
282 | 280 | | |
| |||
311 | 309 | | |
312 | 310 | | |
313 | 311 | | |
314 | | - | |
| 312 | + | |
315 | 313 | | |
316 | 314 | | |
317 | 315 | | |
318 | 316 | | |
319 | | - | |
| 317 | + | |
320 | 318 | | |
321 | 319 | | |
322 | 320 | | |
| |||
0 commit comments