fork(1) download
  1. using System;
  2. using System.Diagnostics;
  3.  
  4. struct Struct
  5. {
  6. public int X;
  7. public int Y;
  8.  
  9. public Struct(int x, int y)
  10. {
  11. X = x; Y = y;
  12. }
  13. }
  14.  
  15. class Hoge
  16. {
  17. public static void Main()
  18. {
  19. Struct s = default(Struct);
  20.  
  21. Stopwatch sw = new Stopwatch();
  22. sw.Start();
  23.  
  24. int total = 0;
  25.  
  26. for (int i = 0; i < 100*100000; ++i)
  27. {
  28. s = new Struct(i, i*2);
  29. total += s.X;
  30. total += s.Y;
  31. }
  32.  
  33. sw.Stop();
  34. Console.WriteLine("" + total + " " + s.Y + " " + sw.ElapsedMilliseconds);
  35.  
  36. total = 0;
  37.  
  38. sw.Reset();
  39. sw.Start();
  40.  
  41. for (int i = 0; i < 100 * 100000; ++i)
  42. {
  43. s.X = i;
  44. s.Y = i*2;
  45.  
  46. total += s.X;
  47. total += s.Y;
  48. }
  49.  
  50. sw.Stop();
  51. Console.WriteLine("" + total + " " + s.Y + " " + sw.ElapsedMilliseconds);
  52. }
  53. }
Success #stdin #stdout 0.08s 33800KB
stdin
Standard input is empty
stdout
-1747812800 19999998  23
-1747812800 19999998  24