示例#1
0
        private static void TestComputeMethod(int arraySize)
        {
            Stopwatch stopwatch = new Stopwatch();
            ArrayGenerator generator = new ArrayGenerator();

            Console.WriteLine("------------------------------------");
            Console.WriteLine("Method Compute runs in quadratic time O(n*n)");
            Console.WriteLine("Size of the array = {0}", arraySize);

            int[] generatedArray = generator.GenerateArray(arraySize);

            stopwatch.Start();
            long result = Compute(generatedArray);
            stopwatch.Stop();

            Console.WriteLine("Time: {0}", stopwatch.Elapsed);
            Console.WriteLine("Result = {0}", result);
            Console.WriteLine("------------------------------------\n");
        }
示例#2
0
        private static void TestComputeMethod(int rows, int cols)
        {
            Stopwatch stopwatch = new Stopwatch();
            ArrayGenerator generator = new ArrayGenerator();

            Console.WriteLine("--------------------------------------------");
            Console.WriteLine("Method CalcSum runs in quadratic time O(n*m)");
            Console.WriteLine("Size of the array = [{0}, {1}]", rows, cols);

            int[,] generatedArray = generator.GenerateTwoDimensionalArray(rows, cols);

            stopwatch.Start();
            long counterSmallArray = CalcSum(generatedArray, 0);
            stopwatch.Stop();

            Console.WriteLine("Time: {0}", stopwatch.Elapsed);
            Console.WriteLine("Result = {0}", counterSmallArray);
            Console.WriteLine("--------------------------------------------\n");
        }