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];
int test = 20;
for (int loop = 0; loop < 4; loop++)
{
watch = Stopwatch.StartNew();
for (int i = 0; i < count; i++)
{
for (int j = 0; j < test; ++j)
{
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();
for (int j = 0; j < test; ++j)
{
s[i] = bulder.Append(a).Append(b).Append(c).Append(d).Append(e).Append(f).Append(g).Append(h).ToString();
bulder.Clear();
}
}
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";
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uRGlhZ25vc3RpY3M7CnVzaW5nIFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljOwp1c2luZyBTeXN0ZW0uTGlucTsKdXNpbmcgU3lzdGVtLlRleHQ7CgpuYW1lc3BhY2UgQ29uc29sZUFwcGxpY2F0aW9uMQp7CiAgY2xhc3MgUHJvZ3JhbQogIHsKICAgIHN0YXRpYyB2b2lkIE1haW4oc3RyaW5nW10gYXJncykKICAgIHsKICAgICAgU3RvcHdhdGNoIHdhdGNoOwoKICAgICAgc3RyaW5nIGEsIGIsIGMsIGQsIGUsIGYsIGcsIGg7CiAgICAgIFNldFN0cmluZyhvdXQgYSwgb3V0ICBiLCBvdXQgIGMsIG91dCBkLCBvdXQgZSwgb3V0IGYsIG91dCBnLCBvdXQgaCk7CgogICAgICBpbnQgY291bnQgPSAxMDAwMDA7CiAgICAgIHN0cmluZ1tdIHMgPSBuZXcgc3RyaW5nW2NvdW50XTsKICAgICAgaW50IHRlc3QgPSAyMDsKCiAgICAgIGZvciAoaW50IGxvb3AgPSAwOyBsb29wIDwgNDsgbG9vcCsrKQogICAgICB7CiAgICAgICAgd2F0Y2ggPSBTdG9wd2F0Y2guU3RhcnROZXcoKTsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IGNvdW50OyBpKyspCiAgICAgICAgewogICAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCB0ZXN0OyArK2opCiAgICAgICAgICB7CiAgICAgICAgICAgIHNbaV0gPSBhICsgYiArIGMgKyBkICsgZSArIGYgKyBnICsgaDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgd2F0Y2guU3RvcCgpOwogICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCIrOiIgKyB3YXRjaC5FbGFwc2VkTWlsbGlzZWNvbmRzKTsKCiAgICAgICAgd2F0Y2ggPSBTdG9wd2F0Y2guU3RhcnROZXcoKTsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IGNvdW50OyBpKyspCiAgICAgICAgewogICAgICAgICAgU3RyaW5nQnVpbGRlciBidWxkZXIgPSBuZXcgU3RyaW5nQnVpbGRlcigpOwogICAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCB0ZXN0OyArK2opCiAgICAgICAgICB7CiAgICAgICAgICAgIHNbaV0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