Project

General

Profile

Actions

Bug #13340

closed

Improve performance of Array#sort with float elements

Added by watson1978 (Shizuo Fujita) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Target version:
-
[ruby-dev:50023]

Description

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

Actions

Also available in: Atom PDF

Like0
Like0Like0