From: Todd Benson Date: 2008-09-24T13:58:18+09:00 Subject: Re: Breaking apart arrays for arguments? On Tue, Sep 23, 2008 at 3:19 PM, Kyle Schmitt wrote: > On Tue, Sep 23, 2008 at 2:19 PM, Kyle Schmitt wrote: >>> I run your code without any changes, and I got: >>> >>> user system total real >>> unshift pure 1.469000 0.046000 1.515000 ( 1.547000) >>> unshift, flatten at end 3.156000 1.047000 4.203000 ( 4.250000) >>> >>> RUBY_VERSION 1.8.6, RUBY_PATCHLEVEL 287, RUBY_RELEASE_DATE 2008-08-11 >>> Windows One-Click Installer >>> >>> That's strange. >>> >>> TPR. >> >> Very odd indeed, because those are more like the numbers I would have expected! >> then again I'm running an old old version, the official binary for CentOS: >> ruby 1.8.5 (2006-08-25) >> >> Guess I need to compile something better. > > Even wierder now. I grabbed the latest 1.9 source from subversion > compiled & installed. > > The 1.9 times are better than I was getting with 1.8.5, but unshift, > flatten was still hugely faster.... I'm gonna have to try this again > at home with a box that has 1.8.6 on it. > > with 1.9 from subversion > user system total real > unshift pure 3.900000 0.110000 4.010000 ( 4.691366) > unshift, flatten at end 0.430000 0.010000 0.440000 ( 0.501283) > > with 1.8.5 > user system total real > unshift pure 4.050000 0.670000 4.720000 ( 5.635800) > unshift, flatten at end 1.660000 0.570000 2.230000 ( 2.413984) I get the same numbers. Not knowing the internal workings of Ruby, it seems pretty obvious that this has to do with the fact you are not running flattening 1024 times, but you are splatting that many times. Todd