fork(1) download
  1. using System;
  2. using System.Diagnostics;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Stopwatch watch;
  14.  
  15. string a, b, c, d, e, f, g, h;
  16. SetString(out a, out b, out c, out d, out e, out f, out g, out h);
  17.  
  18. int count = 100000;
  19. string[] s = new string[count];
  20.  
  21. for (int loop = 0; loop < 4; loop++)
  22. {
  23. watch = Stopwatch.StartNew();
  24. for (int i = 0; i < count; i++)
  25. {
  26. s[i] = a + b + c + d + e + f + g + h;
  27. }
  28. watch.Stop();
  29. Console.WriteLine("+:" + watch.ElapsedMilliseconds);
  30.  
  31. watch = Stopwatch.StartNew();
  32. for (int i = 0; i < count; i++)
  33. {
  34. StringBuilder bulder = new StringBuilder();
  35. bulder.Append(a).Append(b).Append(c).Append(d).Append(e).Append(f).Append(g).Append(h);
  36. s[i] = bulder.ToString();
  37. }
  38. watch.Stop();
  39. Console.WriteLine("StringBuilder:" + watch.ElapsedMilliseconds);
  40. }
  41. }
  42.  
  43. [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
  44. 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)
  45. {
  46. a = "AAAAAAAAAAAAAAAAA";
  47. b = "BBBBBBBBBBBBBBBBBBBBBBBB";
  48. c = "CCCCCCCCCCCCCCCCCCCC";
  49. d = "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD";
  50. e = "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE";
  51. f = "FFFFFFFFFFFFFFFFFFFFFF";
  52. g = "GGGGGGGGGGGGGGGGG";
  53. h = "HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH";
  54. }
  55.  
  56. }
  57. }
  58.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty