单线程测试
测试次数:5
测量单位:毫微秒
测试类:
StringBuilder 线程不安全 stringBuilder.append("someString");
StringBuffer 线程安全 stringBuffer.append("someString");
String 普通 str1 + str2
循环添加次数:1000000(由于普通的String“+"字符操作1000000根本跑不动,所以用的是10000)
StringBuilder
cost time: 97973625
cost time: 84470233
cost time: 85545509
cost time: 84069902
cost time: 83813725
cost time: 95636457
cost time: 78379795
StringBuffer
cost time: 157424197
cost time: 138400272
cost time: 140522608
cost time: 144071663
cost time: 89715872
cost time: 103994782
cost time: 84376087
String
cost time: 653045010
cost time: 668044961
cost time: 631079928
cost time: 634437338
cost time: 639070049
cost time: 626573489
cost time: 635229338