[macruby-changes] [MacRuby/MacRuby] e664c0: improve a performance in String#+
GitHub
noreply at github.com
Sat Dec 29 19:14:44 PST 2012
Branch: refs/heads/master
Home: https://github.com/MacRuby/MacRuby
Commit: e664c0ecdd615885ea9ce12ff18d71cd50d9a321
https://github.com/MacRuby/MacRuby/commit/e664c0ecdd615885ea9ce12ff18d71cd50d9a321
Author: Watson <watson1978 at 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
More information about the macruby-changes
mailing list