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. for (int i = 0; i < 100*100000; ++i)
  25. {
  26. s = new Struct(i, i*2);
  27. }
  28.  
  29. sw.Stop();
  30. Console.WriteLine("" + s.Y + " " + sw.ElapsedMilliseconds);
  31.  
  32. sw.Reset();
  33. sw.Start();
  34.  
  35. for (int i = 0; i < 100 * 100000; ++i)
  36. {
  37. s.X = i;
  38. s.Y = i*2;
  39. }
  40.  
  41. sw.Stop();
  42. Console.WriteLine("" + s.Y + " " + sw.ElapsedMilliseconds);
  43. }
  44. }
Success #stdin #stdout 0.06s 33768KB
stdin
Standard input is empty
stdout
19999998  11
19999998  13