using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Stopwatch watch;
string a, b, c, d, e, f, g, h;
SetString(out a, out b, out c, out d, out e, out f, out g, out h);
int count = 100000;
string[] s = new string[count];
for (int loop = 0; loop < 4; loop++)
{
watch = Stopwatch.StartNew();
for (int i = 0; i < count; i++)
{
s[i] = a + b + c + d + e + f + g + h;
}
watch.Stop();
Console.WriteLine("+:" + watch.ElapsedMilliseconds);
watch = Stopwatch.StartNew();
for (int i = 0; i < count; i++)
{
StringBuilder bulder = new StringBuilder();
bulder.Append(a).Append(b).Append(c).Append(d).Append(e).Append(f).Append(g).Append(h);
s[i] = bulder.ToString();
}
watch.Stop();
Console.WriteLine("StringBuilder:" + watch.ElapsedMilliseconds);
}
}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
static void SetString(out string a, out string b, out string c, out string d, out string e, out string f, out string g, out string h)
{
a = "AAAAAAAAAAAAAAAAA";
b = "BBBBBBBBBBBBBBBBBBBBBBBB";
c = "CCCCCCCCCCCCCCCCCCCC";
d = "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD";
e = "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE";
f = "FFFFFFFFFFFFFFFFFFFFFF";
g = "GGGGGGGGGGGGGGGGG";
h = "HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH";
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uRGlhZ25vc3RpY3M7CnVzaW5nIFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljOwp1c2luZyBTeXN0ZW0uTGlucTsKdXNpbmcgU3lzdGVtLlRleHQ7CgpuYW1lc3BhY2UgQ29uc29sZUFwcGxpY2F0aW9uMQp7CiAgICBjbGFzcyBQcm9ncmFtCiAgICB7CiAgICAgICAgc3RhdGljIHZvaWQgTWFpbihzdHJpbmdbXSBhcmdzKQogICAgICAgIHsKICAgICAgICAgICAgU3RvcHdhdGNoIHdhdGNoOwoKICAgICAgICAgICAgc3RyaW5nIGEsIGIsIGMsIGQsIGUsIGYsIGcsIGg7CiAgICAgICAgICAgIFNldFN0cmluZyhvdXQgYSwgb3V0ICBiLCBvdXQgIGMsIG91dCBkLCBvdXQgZSwgb3V0IGYsIG91dCBnLCBvdXQgaCk7CgogICAgICAgICAgICBpbnQgY291bnQgPSAxMDAwMDA7CiAgICAgICAgICAgIHN0cmluZ1tdIHMgPSBuZXcgc3RyaW5nW2NvdW50XTsKCiAgICAgICAgICAgIGZvciAoaW50IGxvb3AgPSAwOyBsb29wIDwgNDsgbG9vcCsrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICB3YXRjaCA9IFN0b3B3YXRjaC5TdGFydE5ldygpOwogICAgICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBjb3VudDsgaSsrKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHNbaV0gPSBhICsgYiArIGMgKyBkICsgZSArIGYgKyBnICsgaDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHdhdGNoLlN0b3AoKTsKICAgICAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIrOiIgKyB3YXRjaC5FbGFwc2VkTWlsbGlzZWNvbmRzKTsKCiAgICAgICAgICAgICAgICB3YXRjaCA9IFN0b3B3YXRjaC5TdGFydE5ldygpOwogICAgICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBjb3VudDsgaSsrKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIFN0cmluZ0J1aWxkZXIgYnVsZGVyID0gbmV3IFN0cmluZ0J1aWxkZXIoKTsKICAgICAgICAgICAgICAgICAgICBidWxkZXIuQXBwZW5kKGEpLkFwcGVuZChiKS5BcHBlbmQoYykuQXBwZW5kKGQpLkFwcGVuZChlKS5BcHBlbmQoZikuQXBwZW5kKGcpLkFwcGVuZChoKTsKICAgICAgICAgICAgICAgICAgICBzW2ldID0gYnVsZGVyLlRvU3RyaW5nKCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB3YXRjaC5TdG9wKCk7CiAgICAgICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiU3RyaW5nQnVpbGRlcjoiICsgd2F0Y2guRWxhcHNlZE1pbGxpc2Vjb25kcyk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIFtTeXN0ZW0uUnVudGltZS5Db21waWxlclNlcnZpY2VzLk1ldGhvZEltcGwoU3lzdGVtLlJ1bnRpbWUuQ29tcGlsZXJTZXJ2aWNlcy5NZXRob2RJbXBsT3B0aW9ucy5Ob0lubGluaW5nKV0KICAgICAgICBzdGF0aWMgdm9pZCBTZXRTdHJpbmcob3V0IHN0cmluZyBhLCBvdXQgc3RyaW5nIGIsIG91dCBzdHJpbmcgYywgb3V0IHN0cmluZyBkLCBvdXQgc3RyaW5nIGUsIG91dCBzdHJpbmcgZiwgb3V0IHN0cmluZyBnLCBvdXQgc3RyaW5nIGgpCiAgICAgICAgewogICAgICAgICAgICBhID0gIkFBQUFBQUFBQUFBQUFBQUFBIjsKICAgICAgICAgICAgYiA9ICJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkIiOwogICAgICAgICAgICBjID0gIkNDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDIjsKICAgICAgICAgICAgZCA9ICJEREREREREREREREREREREREREREREREREREREREREREREREREREREREQiOwogICAgICAgICAgICBlID0gIkVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRSI7CiAgICAgICAgICAgIGYgPSAiRkZGRkZGRkZGRkZGRkZGRkZGRkZGRiI7CiAgICAgICAgICAgIGcgPSAiR0dHR0dHR0dHR0dHR0dHR0ciOwogICAgICAgICAgICBoID0gIkhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEhISEgiOwogICAgICAgIH0KCiAgICB9Cn0K