Commit fd8ef89
committed
Changed to
## Why? Because `s.check("a")` is slower than `s.check("a".freeze)`. - benchmark/stringscan_2.yaml ``` loop_count: 100000 contexts: - name: No YJIT prelude: | $LOAD_PATH.unshift(File.expand_path("lib")) require 'rexml' prelude: | require 'strscan' s = StringScanner.new('abcdefg hijklmn opqrstu vwxyz') ptn = "a" benchmark: 'check("a")' : s.check("a") 'check("a".freeze)' : s.check("a".freeze) 'ptn="a";s.check(ptn)' : | ptn="a" s.check(ptn) 'check(ptn)' : s.check(ptn) ``` ``` $benchmark-driver benchmark/stringscan_2.yaml Comparison: check(ptn): 13524479.4 i/s check("a".freeze): 13433638.1 i/s - 1.01x slower check("a"): 10231225.8 i/s - 1.32x slower ptn="a";s.check(ptn): 10013017.0 i/s - 1.35x slower ```frozen_string_literal: true.1 parent fb7ba27 commit fd8ef89
1 file changed
+2
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
465 | | - | |
466 | | - | |
| 465 | + | |
467 | 466 | | |
468 | 467 | | |
469 | 468 | | |
| |||
0 commit comments