5 ms·
when concatenating strings, stringbuffer can be orders of magnitude faster. one c# example from google search "stringbuilder vs string benchmark" from codinggam
by xaedes 7y ago
when concatenating strings, stringbuffer can be orders of magnitude faster. one c# example from google search "stringbuilder vs string benchmark" from codinggame.com measures 2.5 minutes for string += and 99ms for stringbuilder.
- xaedes 7y agosry i meant stringbuilder, not stringbuffer.
- davedx 7y agoMaybe for Python a stringbuilder is faster, but for JavaScript, += is faster. https://jsperf.com/javascript-concat-vs-join/2 https://jsperf.com/javascript-concat-vs-join/2 Don't assume a certain way of coding is faster because you read it on the Internet, actually profile your code.
- speedplane 7y ago> Maybe for Python a stringbuilder is faster, but for JavaScript, += is faster. I am amazed and saddened, that in 2020, concatenating strings, regardless of the form or language, is not blazing fast across all environments.