Optimisation - Array intersection over selection
Closed this issue · 0 comments
luke-hill commented
Ran a quick fast-ruby style optimisation check. For the code here: https://github.com/site-prism/site_prism-all_there/blob/main/lib/site_prism/all_there/expected_items.rb#L68
Warming up --------------------------------------
array select and include
21.776k i/100ms
array intersection 74.987k i/100ms
Calculating -------------------------------------
array select and include
220.481k (± 3.4%) i/s - 1.111M in 5.043750s
array intersection 741.762k (± 3.6%) i/s - 3.749M in 5.062687s
Comparison:
array intersection: 741761.5 i/s
array select and include: 220480.7 i/s - 3.36x slower