[macruby-changes] [MacRuby/MacRuby] a62158: Optimize the rary_insert().

noreply at github.com noreply at github.com
Sat Jun 18 17:59:50 PDT 2011


  Branch: refs/heads/master
  Home:   https://github.com/MacRuby/MacRuby

  Commit: a62158335e63440b9aea2efa5dab7133c1a769ae
      https://github.com/MacRuby/MacRuby/commit/a62158335e63440b9aea2efa5dab7133c1a769ae
  Author: Watson <watson1978 at gmail.com>
  Date:   2011-06-18 (Sat, 18 Jun 2011)

  Changed paths:
    M array.c

  Log Message:
  -----------
  Optimize the rary_insert().

* before
                               user     system      total        real
filled object / string     0.990000   0.000000   0.990000 (  0.981791)
filled object / numeric    0.930000   0.000000   0.930000 (  0.928791)
empty array / string       0.160000   0.010000   0.170000 (  0.095161)
empty array / numeric      0.010000   0.000000   0.010000 (  0.015316)

* after
                               user     system      total        real
filled object / string     0.060000   0.000000   0.060000 (  0.057018)
filled object / numeric    0.050000   0.000000   0.050000 (  0.051273)
empty array / string       0.080000   0.000000   0.080000 (  0.045073)
empty array / numeric      0.020000   0.000000   0.020000 (  0.014007)

{{{
require 'benchmark'

Benchmark.bm(25) do |x|

  ary  = ['obj'] * 10000
  x.report "filled object / string" do
    1000.times do
      ary.unshift("a")
    end
  end

  ary  = ['obj'] * 10000
  x.report "filled object / numeric" do
    1000.times do
      ary.unshift(0)
    end
  end

  ary = Array.new(10000)
  x.report "empty array / string" do
    1000.times do
      ary.unshift("a")
    end
  end

  ary = Array.new(10000)
  x.report "empty array / numeric" do
    1000.times do
      ary.unshift(0)
    end
  end

end
}}}


  Commit: c8904441799454d9bb027d75bab31086e5dc3977
      https://github.com/MacRuby/MacRuby/commit/c8904441799454d9bb027d75bab31086e5dc3977
  Author: Watson <watson1978 at gmail.com>
  Date:   2011-06-18 (Sat, 18 Jun 2011)

  Changed paths:
    M array.c

  Log Message:
  -----------
  Optimize the ary_shared_first().

* before
                user     system      total        real
shift       1.410000   0.020000   1.430000 (  0.778395)
shift(10)   0.910000   0.040000   0.950000 (  0.718543)
shift(100)  1.830000   0.090000   1.920000 (  1.379111)

* after
                user     system      total        real
shift       1.410000   0.030000   1.440000 (  0.778768)
shift(10)   0.970000   0.030000   1.000000 (  0.720666)
shift(100)  1.190000   0.080000   1.270000 (  0.890673)

{{{
require 'benchmark'

Benchmark.bm(10) do |x|

  x.report "shift" do
    50.times do
      ary  = ['obj'] * 100000
      1000.times do
        ary.shift
      end
    end
  end

  x.report "shift(10)" do
    50.times do
      ary  = ['obj'] * 100000
      1000.times do
        ary.shift(10)
      end
    end
  end

  x.report "shift(100)" do
    50.times do
      ary  = ['obj'] * 100000
      1000.times do
        ary.shift(100)
      end
    end
  end

end
}}}


Compare: https://github.com/MacRuby/MacRuby/compare/94a97d3...c890444


More information about the macruby-changes mailing list