Java string splicing and performance analysis

Suppose there is a string, we will do a lot of circular splicing operations on this string. If "+" is used, we will get the lowest performance. But how bad is this performance? If we also put StringBuffer, StringBuilder or string What happens when concat () is put into the performance test? This article will give an answer to these questions!

We will use per4j to calculate performance, because this tool can give us a complete set of performance indicators, such as minimum and maximum time consumption, standard deviation of statistical time period, etc. In the test code, in order to obtain an accurate standard deviation value, we will perform 50000 tests of 20 splices "*". The following is the method we will use to splice strings:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>