private static readonly string STR = "0123456789";/************************************
The string. Concat method is used for common connection operations. A new string is generated each time.
*************************************/private static string NormalConcat(int count){ var result = ""; for (int i = 0; i < count; i++) result += STR; return result;}/*****************************
Almost all the time is spent on the append operation (this is nonsense ). In the append method, the appendinplace and getnewstring Methods Both occupy a large proportion.
From the previous code analysis, we know that the appendinplace method copies the new string to the back of the original character sequence (that is, the "Container,
The function of getnewstring is to create a new, doubling capacity string (container)-the main consumption of it is on the getstringforstringbuilder method.
******************************/private static string StringBuilder(int count){ var builder = new StringBuilder(); for (int i = 0; i < count; i++) builder.Append(STR); return builder.ToString();}
More discussion: http://blog.zhaojie.me/2009/11/string-concat-perf-1-benchmark.html