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();
StringBuilder bulder = new StringBuilder();
for (int i = 0; i < count; i++)
{
bulder.Append(a).Append(b).Append(c).Append(d).Append(e).Append(f).Append(g).Append(h);
s[i] = bulder.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";
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uRGlhZ25vc3RpY3M7CnVzaW5nIFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljOwp1c2luZyBTeXN0ZW0uTGlucTsKdXNpbmcgU3lzdGVtLlRleHQ7CgpuYW1lc3BhY2UgQ29uc29sZUFwcGxpY2F0aW9uMQp7CiAgY2xhc3MgUHJvZ3JhbQogIHsKICAgIHN0YXRp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