Skip to content

Rewrite Array#each with Ruby #3658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

S-H-GAMELINKS
Copy link
Contributor

benchmark:

sh@DESKTOP-L0NI312:~/rubydev/build$ make benchmark/benchmark.yml -e COMPARE_RUBY=~/.rbenv/shims/ruby -e BENCH_RUBY=../install/bin/ruby -e BENCH_OPTS=--repeat-count=4compiling ../ruby/array.c
linking miniruby
Warming up --------------------------------------
             Array.new(10).each       5.018M i/s -      5.108M times in 1.017995s (199.28ns/i, 516clocks/i)
        Array.new(10).each{|v|}       2.589M i/s -      2.670M times in 1.031188s (386.24ns/i)
      Array.new(1000).each{|v|}      36.987k i/s -     39.853k times in 1.077472s (27.04μs/i)
Array.new(30_000_000).each{|v|}        1.146 i/s -       2.000 times in 1.744604s (872.30ms/i)
Calculating -------------------------------------
                                compare-ruby  built-ruby 
             Array.new(10).each       5.300M      4.547M i/s -     15.054M times in 2.840237s 3.310539s
        Array.new(10).each{|v|}       2.467M      2.491M i/s -      7.767M times in 3.148073s 3.118684s
      Array.new(1000).each{|v|}      36.285k     36.179k i/s -    110.962k times in 3.058095s 3.066989s
Array.new(30_000_000).each{|v|}        1.141       1.141 i/s -       3.000 times in 2.629663s 2.630178s
Comparison:
                          Array.new(10).each
                   compare-ruby:   5300298.8 i/s 
                     built-ruby:   4547328.5 i/s - 1.17x  slower
                     Array.new(10).each{|v|}
                     built-ruby:   2490562.6 i/s 
                   compare-ruby:   2467311.5 i/s - 1.01x  slower
                   Array.new(1000).each{|v|}
                   compare-ruby:     36284.7 i/s 
                     built-ruby:     36179.5 i/s - 1.00x  slower
             Array.new(30_000_000).each{|v|}
                   compare-ruby:         1.1 i/s 
                     built-ruby:         1.1 i/s - 1.00x  slower

ref: #3656

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.

1 participant