Skip to content
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

Array is faster than Hash #284

Open
azumakuniyuki opened this issue May 12, 2024 · 0 comments
Open

Array is faster than Hash #284

azumakuniyuki opened this issue May 12, 2024 · 0 comments
Labels
improvement speed-up Performance Tuning

Comments

@azumakuniyuki
Copy link
Member

% ruby -v
ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-darwin18]
% ruby array-vs-hash.rb
ok
ok
Rehearsal --------------------------------------------
Array#[]   1.625212   0.022531   1.647743 (  1.876507)
Hash#[]    2.695574   0.032553   2.728127 (  3.927084)
----------------------------------- total: 4.375870sec

               user     system      total        real
Array#[]   1.778634   0.026975   1.805609 (  2.216943)
Hash#[]    2.386689   0.033003   2.419692 (  2.665415)
ruby array-vs-hash.rb  8.60s user 0.14s system 80% cpu 10.932 total
% /opt/local/bin/ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin21]
% /opt/local/bin/ruby ./array-vs-hash.rb
ok
ok
Rehearsal --------------------------------------------
Array#[]   1.550450   0.013008   1.563458 (  1.597389)
Hash#[]    1.991518   0.012844   2.004362 (  2.022441)
----------------------------------- total: 3.567820sec

               user     system      total        real
Array#[]   1.639153   0.013144   1.652297 (  1.672645)
Hash#[]    2.539378   0.022435   2.561813 (  2.734693)
/opt/local/bin/ruby ./array-vs-hash.rb  7.87s user 0.11s system 96% cpu 8.288 total
@azumakuniyuki azumakuniyuki added improvement speed-up Performance Tuning labels May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement speed-up Performance Tuning
Projects
None yet
Development

No branches or pull requests

1 participant