At what point does using a StringBuilder become insignificant or an overhead?

后端 未结 7 1414
轻奢々
轻奢々 2020-12-03 14:17

Recently I have found myself using StringBuilder for all string concatenations, big and small, however in a recent performance test I swapped out a colleague\'s stringOu

7条回答
  •  失恋的感觉
    2020-12-03 14:40

    There's an interesting article on this over at Coding Horror. Jeff got the following results for 100,000 iterations on a dual core 3.5 GHz Core 2 Duo:

     Simple Concatenation    - 606 ms
     String.Format           - 665 ms
     string.Concat           - 587 ms
     String.Replace          - 979 ms
     StringBuilder           - 588 ms
    

提交回复
热议问题