summaryrefslogtreecommitdiff
path: root/benchmark/bm_so_random.rb
diff options
context:
space:
mode:
authorSutou Kouhei <kou@clear-code.com>2026-06-01 16:54:36 +0900
committergit <svn-admin@ruby-lang.org>2026-06-01 07:55:02 +0000
commite73e4f2d4cbbd741649572b840e3a9816c31bb17 (patch)
tree81438bba1ee2283b071fe187e778b5c2581c7eb7 /benchmark/bm_so_random.rb
parent2a6353e2e51e5d6bb88e8aa18c50be55f2d49333 (diff)
[ruby/strscan] [Feature #21943] Add `StringScanner#integer_at`HEADmaster
(https://github.com/ruby/strscan/pull/205) See also: https://bugs.ruby-lang.org/issues/21943 This is semantically equivalent to `scanner[specifier]&.to_i(base)` but this is faster than `scanner[specifier]&.to_i(base)` because `integer_at` doesn't create a temporary String when possible. This PR also includes a benchmark for them: ```console $ ruby -v -S benchmark-driver benchmark/integer_at.yaml ruby 4.1.0dev (2026-05-01T19:25:51Z master https://github.com/ruby/strscan/commit/f2845eab29) +PRISM [x86_64-linux] Warming up -------------------------------------- [].to_i 24.272M i/s - 25.109M times in 1.034481s (41.20ns/i, 32clocks/i) integer_at 61.188M i/s - 62.491M times in 1.021289s (16.34ns/i, 62clocks/i) Calculating ------------------------------------- [].to_i 26.831M i/s - 72.816M times in 2.713883s (37.27ns/i, 169clocks/i) integer_at 81.331M i/s - 183.564M times in 2.256998s (12.30ns/i, 43clocks/i) Comparison: integer_at: 81331225.5 i/s [].to_i: 26831046.3 i/s - 3.03x slower ``` In this environment, `integer_at` is 3.03x faster than `[].to_i`. https://github.com/ruby/strscan/commit/8a60879b2d Co-authored-by: jinroq <jinroq@gmail.com>
Diffstat (limited to 'benchmark/bm_so_random.rb')
0 files changed, 0 insertions, 0 deletions