Jim Menard wrote:
> Here's a real Array performance mystery. I can't help my friend figure
> this one out. He writes,
>
> ========
>
> Is there a known bug in Ruby array performance? I spent a lot of time
> yesterday boiling down the following example
>
>
> http://blogs.codehaus.org/people/gei...with_ruby.html
>
> only because I still can't believe I'm not doing something incredibly
> stupid. (I'm a newbie, "Reluctant Rubyist")
>
> I'm just not used to arrays behaving this way
Anyone have any
> insight?
>
> ========
>
> He'd love a response in his blog, but with permission I'll copy
> answers here over there. He's not a regular ruby-talk reader...yet.
>
> Jim
>
I am betting Ryan is right about GC issues. JRuby does not fall down
doing this either (which probably also backs up the GC theory):
ruby ~/jruby/scripts/arr_ben.rb
size = 10000 10000
0.050000 0.000000 0.050000 ( 0.057190)
size = 100000 100000
0.660000 0.000000 0.660000 ( 0.67217

size = 1000000 1000000
34.430000 0.340000 34.770000 ( 35.562454)
jruby --server ~/jruby/scripts/arr_ben.rb
size = 10000 10000
0.372000 0.000000 0.372000 ( 0.266000)
size = 100000 100000
0.099000 0.000000 0.099000 ( 0.099000)
size = 1000000 1000000
0.154000 0.000000 0.154000 ( 0.154000)
-Tom