fastruby / fast-ruby

:dash: Writing Fast Ruby :heart_eyes: -- Collect Common Ruby idioms.
https://github.com/fastruby/fast-ruby
5.67k stars 376 forks source link

Compare one n-element hash#merge! vs n assignments with []= #198

Closed ohaleck closed 1 year ago

ohaleck commented 2 years ago

The code/hash/merge-bang-vs-[]=.rb benchmark merges N 1-element hashes to compare it with N hash element assignments using []=. Obviously assignments are faster, but this is not a real-life scenario.

The more common case would be to perform one merge an N-element hash and it appears it is much faster to do it than to perform N assignments. This PR implements such a benchmark.

etagwerker commented 1 year ago

Closing due to inactivity. If anyone is interested in these changes, please submit a new PR addressing all the comments in this PR. Thanks! ❤️