Stream instead of string concatenation
Hi there, it's a little less than a year ago the above issue has been raised by Uko [1]. I run some benchmarks (a little less than year ago :-) With the integration of QA this issue may deserve some attention again. Besides, Uko asked for a feedback. The rule seems to be wrong - it barks on code which is (seems to be) perfectly fine performance-wise, For example: shutUp Class allInstances do:[:cls | Transcript show: 'barking at' , cls name ] See *some* of the benchmark results: http://bit.ly/1GnZ3K0 My interpretation of the result is the following: For small number of concatenations, i.e., up to 5, with no accumulator and with reasonably small strings, i.e., shorter than 50 bytes, it's actually faster to use string concatenation. Using streams is slower, unless one preallocates stream backing string to exactly the size needed. In that case, it's roughly the same as string concatenation using #, You may find full benchmark data at: https://swing.fit.cvut.cz/calipel/archive/943.json https://swing.fit.cvut.cz/calipel/archive/944.json Benchmark source: https://bitbucket.org/janvrany/jv-calipel/src/tip/s/benchmarks/micro/Be nchmarkMicroStringConcat.st?fileviewer=file-view-default https://bitbucket.org/janvrany/jv-calipel/src/tip/s/benchmarks/micro/Be nchmarkMicroStringConcatN.st?fileviewer=file-view-default Indeed, I could have messed up things - we all know about lies, damn lies and benchmarks. HTH, Jan [1]: http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/2014-No vember/103162.html
participants (1)
-
Jan Vrany