[MacRuby] #1157: String#slice is an order of magnitude slower on MacRuby compared to 1.9.2-p136
MacRuby
ruby-noreply at macosforge.org
Thu Jan 26 18:29:10 PST 2012
#1157: String#slice is an order of magnitude slower on MacRuby compared to
1.9.2-p136
------------------------------------+---------------------------------------
Reporter: mrada@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone:
Component: MacRuby | Keywords:
------------------------------------+---------------------------------------
Comment(by watson1978@…):
When duplicates String or slices String with full range, there is no
memory allocation in CRuby19.
- Duplicated String shared pointer to source string's bytes.
- If changes duplicated string, memory allocates and copies source string,
and then, changes string.
I wrote a patch. https://gist.github.com/1686573
{{{
$ ruby19 -v bm_string.rb
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]
user system total real
dup 0.060000 0.010000 0.070000 ( 0.078929)
[0..-1] 0.000000 0.000000 0.000000 ( 0.001177)
[0..-2] 0.060000 0.060000 0.120000 ( 0.110514)
** Before
$ macruby bm_string.rb
user system total real
dup 0.370000 0.020000 0.390000 ( 0.389034)
[0..-1] 0.100000 0.020000 0.120000 ( 0.116802)
[0..-2] 0.100000 0.020000 0.120000 ( 0.120162)
** After
$ macruby bm_string.rb
user system total real
dup 0.020000 0.010000 0.030000 ( 0.015249)
[0..-1] 0.010000 0.000000 0.010000 ( 0.005772)
[0..-2] 0.110000 0.030000 0.140000 ( 0.136033)
}}}
However, When I run RubySpec, displays error message about GC X(
--
Ticket URL: <http://www.macruby.org/trac/ticket/1157#comment:2>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list