[MacRuby/MacRuby] e664c0: improve a performance in String#+
Branch: refs/heads/master Home: https://github.com/MacRuby/MacRuby Commit: e664c0ecdd615885ea9ce12ff18d71cd50d9a321 https://github.com/MacRuby/MacRuby/commit/e664c0ecdd615885ea9ce12ff18d71cd50... Author: Watson <watson1978@gmail.com> Date: 2012-12-29 (Sat, 29 Dec 2012) Changed paths: M string.c Log Message: ----------- improve a performance in String#+ it reserves a heap area to store a concatenated string because it is slow to resize a heap. * before user system total real 0.390000 0.230000 0.620000 ( 0.608497) * after user system total real 0.330000 0.050000 0.380000 ( 0.380267) Test Code: ---- require 'benchmark' str = "abc" * 100 str1 = str * 100 str2 = str * 200 Benchmark.bm do |x| x.report do 10000.times do str1 + str2 end end end
participants (1)
-
GitHub