[macruby-changes] [MacRuby/MacRuby] c1fa68: Performance improvement in str_resize_bytes. becau...

noreply at github.com noreply at github.com
Fri Oct 14 06:17:04 PDT 2011


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

  Commit: c1fa682c149b73ca68b5cb166410a3badd86d015
      https://github.com/MacRuby/MacRuby/commit/c1fa682c149b73ca68b5cb166410a3badd86d015
  Author: Watson <watson1978 at gmail.com>
  Date:   2011-10-14 (Fri, 14 Oct 2011)

  Changed paths:
    M string.c

  Log Message:
  -----------
  Performance improvement in str_resize_bytes. because reallocation of the long string is slow, memory allocate more size than the specified size.

* before
      user     system      total        real
  3.870000   2.790000   6.660000 (  5.048851)

* after
      user     system      total        real
  0.030000   0.010000   0.040000 (  0.037597)

----
require 'benchmark'

Benchmark.bm do |x|
  str = "aaa"
  x.report do
    5000.times do
      str << "x" * rand(1000)
    end
  end

end




More information about the macruby-changes mailing list