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;
s[i] = a;
s[i] += b;
s[i] += c;
s[i] += d;
s[i] += e;
s[i] += f;
s[i] += g;
s[i] += 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";
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uRGlhZ25vc3RpY3M7CnVzaW5nIFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljOwp1c2luZyBTeXN0ZW0uTGlucTsKdXNpbmcgU3lzdGVtLlRleHQ7CgpuYW1lc3BhY2UgQ29uc29sZUFwcGxpY2F0aW9uMQp7CiAgY2xhc3MgUHJvZ3JhbQogIHsKICAgIHN0YXRpYyB2b2lkIE1haW4oc3RyaW5nW10gYXJncykKICAgIHsKICAgICAgU3RvcHdhdGNoIHdhdGNoOwoKICAgICAgc3RyaW5nIGEsIGIsIGMsIGQsIGUsIGYsIGcsIGg7CiAgICAgIFNldFN0cmluZyhvdXQgYSwgb3V0ICBiLCBvdXQgIGMsIG91dCBkLCBvdXQgZSwgb3V0IGYsIG91dCBnLCBvdXQgaCk7CgogICAgICBpbnQgY291bnQgPSAxMDAwMDA7CiAgICAgIHN0cmluZ1tdIHMgPSBuZXcgc3RyaW5nW2NvdW50XTsKCiAgICAgIGZvciAoaW50IGxvb3AgPSAwOyBsb29wIDwgNDsgbG9vcCsrKQogICAgICB7CiAgICAgICAgd2F0Y2ggPSBTdG9wd2F0Y2guU3RhcnROZXcoKTsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IGNvdW50OyBpKyspCiAgICAgICAgewogICAgICAgICAgLy9zW2ldID0gYSArIGIgKyBjICsgZCArIGUgKyBmICsgZyArIGg7CiAgICAgICAgICBzW2ldID0gYTsKICAgICAgICAgIHNbaV0gKz0gYjsKICAgICAgICAgIHNbaV0gKz0gYzsKICAgICAgICAgIHNbaV0gKz0gZDsKICAgICAgICAgIHNbaV0gKz0gZTsKICAgICAgICAgIHNbaV0gKz0gZjsKICAgICAgICAgIHNbaV0gKz0gZzsKICAgICAgICAgIHNbaV0gKz0gaDsKICAgICAgICB9CiAgICAgICAgd2F0Y2guU3RvcCgpOwogICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIrOiIgKyB3YXRjaC5FbGFwc2VkTWlsbGlzZWNvbmRzKTsKCiAgICAgICAgd2F0Y2ggPSBTdG9wd2F0Y2guU3RhcnROZXcoKTsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IGNvdW50OyBpKyspCiAgICAgICAgewogICAgICAgICAgU3RyaW5nQnVpbGRlciBidWxkZXIg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