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

Updated by mrkn (Kenta Murata) over 7 years ago

  • Status changed from Open to Assigned
  • Assignee set to mrkn (Kenta Murata)
Actions #2

Updated by mrkn (Kenta Murata) over 7 years ago

  • Status changed from Assigned to Closed

Applied in changeset trunk|r58333.


array.c: Improve performance of Array#sort with float elements

  • array.c (sort_2): improve performance of Array#sort with float elements.

  • internal.h (cmp_opt_Float, cmp_opt_data): added for checking whether or not
    Float#<=> can be optimizable.

  • numeric.c (rb_float_cmp): added for internal use.

  • internal.h (rb_float_cmp): ditto.

[Bug #13340]
[ruby-dev:50023]
[Fix GH-1539]

Actions

Also available in: Atom PDF

Like0
Like0Like0