Issue #889 has been updated by Yusuke Endoh.

Status changed from Open to Feedback
Assigned to deleted (Masatoshi Seki)

Hi,

> Repeated String concatenation is not as fast or efficient as an array.join('') on a list of strings since the array can know at join time how big the result string should be.


Similar idea was said in [ruby-core:28493].  I like this idea,
but I cannot observe performance improvement by Array#join:


  $ ./ruby -v
  ruby 1.9.2dev (2010-03-25 trunk 27045) [i686-linux]


  # original
  $ time ./ruby -Ilib benchmark/bm_app_erb.rb

  real    0m1.876s
  user    0m1.872s
  sys     0m0.004s


  # use "<<" instead of ".concat"
  $ time ./ruby -Ilib benchmark/bm_app_erb.rb

  real    0m1.813s
  user    0m1.804s
  sys     0m0.016s


  # with proposed patch
  $ time ./ruby -Ilib benchmark/bm_app_erb.rb

  real    0m1.824s
  user    0m1.820s
  sys     0m0.004s


This seems to show using "<<" makes a difference, instead of
Array#join.  I guess it reduces code size emitted by ERB.
But I could be wrong because I just skimped a benchmark.

Could you give me a benchmark proving that Array#join brings
us performance improvement?

-- 
Yusuke Endoh <mame / tsg.ne.jp>
----------------------------------------
http://redmine.ruby-lang.org/issues/show/889

----------------------------------------
http://redmine.ruby-lang.org