Exemple #1
0
        public static void Testing()
        {
            Console.WriteLine("Generating Random Intergers...");
            int[] array = Relevant.GenerateRandomIntergers(300_000_000, 0, 1_000_000);

            Stopwatch sw = new Stopwatch();

            Console.WriteLine("ParallelVersion start:");
            sw.Start();

            GetMaxValueThenPlaceToEnd(array);
            _lengthRequireNewThread = array.Length / 256;
            Task mainTask = null;

            mainTask = new Task(() => Sort_Continuation(array, 0, array.Length - 1, mainTask));
            mainTask.Start();
            while (true)
            {
                Thread.Sleep(500);
                if (_partitionCounter == _finishCounter - 1)
                {
                    break;
                }
            }

            sw.Stop();
            Console.WriteLine($"Total second of Algorithm: {sw.Elapsed}");
            bool result = Relevant.VerifySequence(array);

            Console.WriteLine($"Verification: {result}");
        }
Exemple #2
0
        public static void Testing()
        {
            Console.WriteLine("Generating Random Intergers...");
            int[] array = Relevant.GenerateRandomIntergers(300_000_000, 0, 1_000_000);
            array[array.Length - 1] = int.MaxValue;

            Stopwatch sw = new Stopwatch();

            Console.WriteLine("Non_ParallelVersion start:");
            sw.Start();
            GetMaxValueThenPlaceToEnd(array);
            Sort(array, 0, array.Length - 1);
            sw.Stop();
            Console.WriteLine($"Total second of Algorithm: {sw.Elapsed}");
            bool result = Relevant.VerifySequence(array);

            Console.WriteLine($"Verification: {result}");
        }