fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Runtime.CompilerServices;
  6. using System.Text;
  7.  
  8. namespace ConsoleApplication138
  9. {
  10. internal class Program
  11. {
  12. private const int N = 1000000;
  13.  
  14. private static void Main(string[] args)
  15. {
  16. long trash = 0;
  17. const int a1 = 0, a2 = 1, b = 10;
  18. var result = new long[2][];
  19. for (int i = 0; i < result.Length; i++)
  20. {
  21. result[i] = new long[N];
  22. }
  23. for (int i = 0; i < N; i++)
  24. {
  25. var sw = Stopwatch.StartNew();
  26. int c = Log(a1, b);
  27. int d = Log(a2, b);
  28. sw.Stop();
  29. trash += c + d;
  30. result[0][i] = sw.ElapsedTicks;
  31.  
  32. var sw2 = Stopwatch.StartNew();
  33. c = Ariph(a1, b);
  34. d = Ariph(a2, b);
  35. sw2.Stop();
  36. trash += c + d;
  37. result[1][i] = sw2.ElapsedTicks;
  38. }
  39. Console.WriteLine(trash);
  40. Console.WriteLine("res1 = {0}", result[0].Average());
  41. Console.WriteLine("res2 = {0}", result[0].Average());
  42. Console.ReadKey();
  43. }
  44.  
  45. private static int Log(int a, int b)
  46. {
  47. return a == 0 ? b : a;
  48. }
  49.  
  50. private static int Ariph(int a, int b)
  51. {
  52. return a - a*a*b + b;
  53. }
  54. }
  55. }
Success #stdin #stdout 1.77s 60640KB
stdin
Standard input is empty
stdout
22000000
res1 = 2.590933
res2 = 2.590933