using System;
using System.Diagnostics;
using System.Text;
namespace ConsoleApplication1 {
class Program {
static void Main( string[] args ) {
for( int loop = 0 ; 3 > loop ; loop++ ) {
Stopwatch sw = new Stopwatch();
// +
sw.Start();
string temp1 = "";
for( int i = 0 ; 50000 > i ; i++ ) {
temp1 += "A";
}
sw.Stop();
Console.WriteLine( "+ {0} tick" , sw.ElapsedTicks );
// Reset.
sw.Reset();
// StringBuilder
sw.Start();
StringBuilder sBuf = new StringBuilder( "" );
for( int i = 0 ; 50000 > i ; i++ ) {
sBuf.Append( "A" );
}
sw.Stop();
Console.WriteLine( "StringBuilder {0} tick" , sw.ElapsedTicks );
}
Console.ReadLine();
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uRGlhZ25vc3RpY3M7CnVzaW5nIFN5c3RlbS5UZXh0OwoKbmFtZXNwYWNlIENvbnNvbGVBcHBsaWNhdGlvbjEgewoJY2xhc3MgUHJvZ3JhbSB7CgkJc3RhdGljIHZvaWQgTWFpbiggc3RyaW5nW10gYXJncyApIHsKCQkJZm9yKCBpbnQgbG9vcCA9IDAgOyAzID4gbG9vcCA7IGxvb3ArKyApIHsKCQkJCVN0b3B3YXRjaCBzdyA9IG5ldyBTdG9wd2F0Y2goKTsKCgkJCQkvLyArCgkJCQlzdy5TdGFydCgpOwoJCQkJc3RyaW5nIHRlbXAxID0gIiI7CgkJCQlmb3IoIGludCBpID0gMCA7IDUwMDAwID4gaSA7IGkrKyApIHsKCQkJCQl0ZW1wMSArPSAiQSI7CgkJCQl9CgkJCQlzdy5TdG9wKCk7CgkJCQlDb25zb2xlLldyaXRlTGluZSggIisgICAgICAgICAgICAgezB9IHRpY2siICwgc3cuRWxhcHNlZFRpY2tzICk7CgoJCQkJLy8gUmVzZXQuCgkJCQlzdy5SZXNldCgpOwoKCQkJCS8vIFN0cmluZ0J1aWxkZXIKCQkJCXN3LlN0YXJ0KCk7CgkJCQlTdHJpbmdCdWlsZGVyIHNCdWYgPSBuZXcgU3Ry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