Beispiel #1
0
        static void Main(string[] args)
        {
#if RELEASE
            BenchmarkSwitcher.FromAssembly(Assembly.GetExecutingAssembly()).Run(args);
#else
            while (true)
            {
                Console.WriteLine("Type 0 to exit!");
                Console.Write("Number: ");
                var strNumber = Console.ReadLine();
                if (strNumber == "0")
                {
                    break;
                }

                if (ulong.TryParse(strNumber, out ulong number))
                {
                    var calc = new FibonacciCalc();
                    Console.WriteLine(calc.Recursive(number));
                    Console.WriteLine(calc.RecursiveWithMemoization(number));
                    Console.WriteLine(calc.Iterative(number));
                }
            }
#endif
        }
Beispiel #2
0
        static void Main(string[] args)
        {
#if DEBUG
            var fc = new FibonacciCalc();

            foreach (var n in fc.Data())
            {
                var recursive = fc.Recursive(n);
                var recursiveWithMemoization = fc.RecursiveWithMemoization(n);
                var iterative = fc.Iterative(n);

                Debug.Assert(recursive == recursiveWithMemoization);
                Debug.Assert(recursive == iterative);
            }
#endif

            BenchmarkSwitcher.FromAssembly(Assembly.GetExecutingAssembly()).Run(args);
        }