Hi,

Hmm, I knew it would be slower, but I did not expect this slowdown.�

Thank you both for the explanations. Something to learn every single day :).

Cheers,
Doru



On Sun, Nov 17, 2013 at 9:54 PM, Andres Valloud <avalloud@smalltalk.comcastbiz.net> wrote:
We�re only measuring execution speed, not memory allocation, which is important too.

Yes. �And besides having to collect the garbage at some point, allocation can be costly because the VM has to zero out the string bytes (or nil them if the string is not encoded) and then write on those zeroed (nilled) places with something else. �It takes time.


The length of the strings is a variable as well, of course.

The order also matters, e.g.

� � � � (String new: 7812681237643287423), 'a', 'b', 'c'

and the way you aggregate the result matters as well.


Conclusion, let�s be careful with a too simple advice.

Yes, it's much more complex than it seems when the inefficiency of naive concatenation methods is not flagrant.

Andres.




--
www.tudorgirba.com

"Every thing has its own flow"