DEV Community

Discussion on: 9 tips to Increase your Java performance β˜•οΈ πŸš€ πŸšΆβ€β™‚οΈ

 
sendilkumarn profile image
Sendil Kumar • Edited

StringBuffer is way more efficient than normal String concatenation.

Benchmark                     Mode  Cnt      Score     Error  Units
Benchmark.First.stringBuffer  thrpt   25  52791,073 Β± 196,355  ops/s
Benchmark.First.stringConcat  thrpt   25   7355,182 Β±  39,284  ops/s

And this is on JDK 12.

Thread Thread
 
mt3o profile image
mt3o

For some reason your JDK decided out to replace str concat with stringbuilder.
Look here for more information:
dzone.com/articles/jdk-9jep-280-st...