Beispiel #1
0
        public static void Product(string[] args)
        {
            var    bigN1 = new BigNumber1();
            var    bigN2 = new BigNumber2();
            string x     = args[0];
            string y     = args[1];
            var    watch = Stopwatch.StartNew();
            var    val1  = bigN1.Operations().Multiply(x, y);

            Console.WriteLine(@"Product-1 of the numbers ({0} * {1}) is: {2}", x, y, val1);
            Console.WriteLine("Elapsed Time : {0} seconds", watch.ElapsedMilliseconds / 1000D);
            watch = Stopwatch.StartNew();
            var val2 = bigN2.Operations().Multiply(x, y);

            Console.WriteLine(@"Product-2 of the numbers ({0} * {1}) is: {2}", x, y, val2);
            Console.WriteLine("Elapsed Time : {0} seconds", watch.ElapsedMilliseconds / 1000D);
            Console.WriteLine("Computed Values are {0}!!!", val1.Equals(val2) ? "EQUAL" : "DIFFERENT");
        }
Beispiel #2
0
        public static void Power(string[] args)
        {
            var bigN1 = new BigNumber1();
            var bigN2 = new BigNumber2();
            var bigN3 = new BigNumber3();
            var x     = args[0];
            int y     = Convert.ToInt32(args[1]);
            var watch = Stopwatch.StartNew();
            var val1  = bigN1.Operations().Power(x, y);

            //Console.WriteLine(@"The Power-1 of the numbers ({0} ^ {1}) is: {2}", x, y, val1);
            Console.WriteLine("Elapsed Time for Serial Computation of {0} ^ {1}: {2} seconds", x, y, watch.ElapsedMilliseconds / 1000D);
            watch = Stopwatch.StartNew();
            var val2 = bigN2.Operations().Power(x, y);

            //Console.WriteLine(@"The Power-2 of the numbers ({0} ^ {1}) is: {2}", x, y, val2);
            Console.WriteLine("Elapsed Time for Parallel.For Computation of {0} ^ {1}: {2} seconds", x, y, watch.ElapsedMilliseconds / 1000D);
            watch = Stopwatch.StartNew();
            var val3 = bigN3.Operations().Power(x, y);

            Console.WriteLine("Elapsed Time for Parallel Task Computation of {0} ^ {1}: {2} seconds", x, y, watch.ElapsedMilliseconds / 1000D);
            Console.WriteLine("Computed Values are {0}!!! {1}", val1.Equals(val2) && val2.Equals(val3) ? "EQUAL" : "DIFFERENT", val1);
        }