Closed mateusdeap closed 1 year ago
Hey @rishijain, can you review this PR, please?
Yup, definitely, rerunning the example, the performance is just about the same. Will close this PR and corresponding issue. For future reference, here are the updated results:
ruby -v code/enumerable/each-with-object-vs-inject.rb
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
Warming up --------------------------------------
Enumerable#each_with_object
1.044k i/100ms
Enumerable#inject 1.033k i/100ms
Calculating -------------------------------------
Enumerable#each_with_object
10.554k (± 1.2%) i/s - 53.244k in 5.045839s
Enumerable#inject 10.479k (± 0.7%) i/s - 52.683k in 5.027723s
Comparison:
Enumerable#each_with_object: 10553.7 i/s
Enumerable#inject: 10479.0 i/s - same-ish: difference falls within error
Solves #6