As a part of project optimization, I was considering using a MemoryBlockString like the developer docs propose.
Because I try to use the Xojo framework wherever possible, I had a collection of text properties I wanted to join instead of strings, so I had the idea using a MemoryBlockString couldnt be worth the effort.
Thats why I quickly assembled a benchmark project where you can create a string of a certain length and then use several methods to append it a specified number of times to another string. I was using Text.Join as reference, and the results are very astonishing, I believe (this all on a Mac, 32 Bit build):
Stringlength 1000, 1000 Appends
2422119 Text.Join (100 %)
408085937 Text.+ (16848 %)
255126 String.Join (10 %)
600565917 String.+ (24795 %)
5925048 MemblockString (244 %)
Stringlength 10000, 1000 Appends
26482177 Text.Join (100 %)
849606933 Text.+ (3208 %)
5241943 String.Join (19 %)
102087158 String.+ (385 %)
265321777 MemblockString (1001 %)
Stringlength 10, 100000 Appends
19842773 Text.Join (100 %)
987927978 Text.+ (4978 %)
10728759 String.Join (54 %)
665750976 String.+ (3355 %)
16737792 MemblockString (84 %)
The fastest method throughout all different combinations seems to be String.Join. Sometimes its even amazingly faster than the MemblockString!
Results on 32Bit and 64Bit builds differ, but String.Join always won in my tests.
In case you like to try yourself (or check if I made a mistake): https://dl.dropboxusercontent.com/u/21200221/Xojo/Text%20Append%20Benchmark.zip
EDIT: There was a bug, but it didn’t change anything in the numbers. Project updated.