fork download
  1. using System;
  2. using System.Diagnostics;
  3. using System.Text;
  4.  
  5. namespace ConsoleApplication1 {
  6. class Program {
  7. static void Main( string[] args ) {
  8. for( int loop = 0 ; 3 > loop ; loop++ ) {
  9. Stopwatch sw = new Stopwatch();
  10.  
  11. // +
  12. sw.Start();
  13. string temp1 = "";
  14. for( int i = 0 ; 50000 > i ; i++ ) {
  15. temp1 += "A";
  16. }
  17. sw.Stop();
  18. Console.WriteLine( "+ {0} tick" , sw.ElapsedTicks );
  19.  
  20. // Reset.
  21. sw.Reset();
  22.  
  23. // StringBuilder
  24. sw.Start();
  25. StringBuilder sBuf = new StringBuilder( "" );
  26. for( int i = 0 ; 50000 > i ; i++ ) {
  27. sBuf.Append( "A" );
  28. }
  29. sw.Stop();
  30. Console.WriteLine( "StringBuilder {0} tick" , sw.ElapsedTicks );
  31.  
  32. }
  33. Console.ReadLine();
  34. }
  35. }
  36. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty