------art_543_30243763.1143633139573
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

And the winner is....

-----------------------------------8<--------------------------------------

626/126 > cat stringperf.rb ; ruby stringperf.rb
#!/usr/bin/env ruby
require 'benchmark'

 n = 10000
Benchmark.bm do
        |bm|
        bm.report "String#+     " do
                n.times do
                    actual = ''
                    %w{alpha beta gamma soup}.each do
                        |x|
                        actual = actual + x
                    end
                end
        end # do

        bm.report "Interpolation" do
                n.times do
                    %w{alpha beta gamma soup}.each do
                        |x|
                        actual = "#{actual}#{x}"
                    end
                end
        end # do

        bm.report "Format       " do
                n.times do
                    %w{alpha beta gamma soup}.each do
                        |x|
                        actual = "%s%s" % [actual, x]
                    end
                end
        end
 end # do


      user     system      total        real
String#+       0.090000   0.000000   0.090000 (  0.109451)
Interpolation  0.150000   0.000000   0.150000 (  0.153926)
Format         0.210000   0.000000   0.210000 (  0.226805)
-----------------------------------8<--------------------------------------
Robert

--
Deux choses sont infinies : l'univers et la bóŐise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.

- Albert Einstein

------art_543_30243763.1143633139573--