[ruby-dev:50023] [Ruby trunk Bug#13340] Improve performance of Array#sort with float elements

From: watson1978@...
Date: 2017-03-21 00:42:02 UTC
List: ruby-dev #50023
Issue #13340 has been reported by watson1978 (Shizuo Fujita).

----------------------------------------
Bug #13340: Improve performance of Array#sort with float elements
https://bugs.ruby-lang.org/issues/13340

* Author: watson1978 (Shizuo Fujita)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Array#sort with float elements will be over 2 times faster.

### Before
~~~
       user     system      total        real
   5.650000   0.020000   5.670000 (  5.661151)
~~~

### After
~~~
       user     system      total        real
   2.410000   0.010000   2.420000 (  2.427718)
~~~

### Test code
~~~
require 'benchmark'

Benchmark.bmbm do |x|

  ary = []
  1000.times { |i| ary << Random.rand }

  x.report do

    10000.times do
      ary.sort
    end

  end

end
~~~

### Patch
The patch is in https://github.com/ruby/ruby/pull/1539



-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next