Open ydakuka opened 9 months ago
I've benchmarked it (ruby 3.3.0).
ydakuka@yauhenid:~/ruby-docker-app$ docker run ruby-app
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]
Warming up --------------------------------------
Array#unshift 15.000 i/100ms
Array#insert 1.000 i/100ms
Calculating -------------------------------------
Array#unshift 137.945 (± 4.3%) i/s - 690.000 in 5.013164s
Array#insert 1.050 (± 0.0%) i/s - 6.000 in 5.726303s
Comparison:
Array#unshift: 137.9 i/s
Array#insert: 1.0 i/s - 131.38x slower
real-world-ruby-apps - 18 matches across 16 files real-world-rails - 25 matches across 22 files
https://github.com/fastruby/fast-ruby#arrayinsert-vs-arrayunshift-code
Describe the solution you'd like
Rubocop