Ruby 2.4 has optimized
Array#max methods. Here are some benchmarks.
Array class took methods from
Enumerable mixin which included the
2.4, array has its own
max methods which are way faster than the old ones.
These methods now completely skip the call to
Ruby maintainers claim it will benificial in big data operations where
min/max are the most basic and frequent operations.
Simple script for benchmarking: (using shuffle to remove the chance of algorithm being biased towards sorted arrays)
Running these benchmarks on my macbook air. First on
And now on
This is a whopping 20x performace gain!
2.4-preview1release announcement: https://www.ruby-lang.org/en/news/2016/06/20/ruby-2-4-0-preview1-released/
- Rubylang issue tracker: https://bugs.ruby-lang.org/issues/12172