Exemplo n.º 1
0
        public async Task ParallelQuickSort()
        {
            var qs = new ParallelQuickSorter <int>();

            var tasks = new Task <TimeSpan> [5];

            for (int j = 0; j < tasks.Length; j++)
            {
                tasks[j] = Task.Run(() => QuickSortRoutine(qs));
            }

            await Task.WhenAll(tasks);

            Yellow.WriteLine(
                $"Average time is {new TimeSpan(Convert.ToInt64(tasks.Average(task => task.Result.Ticks)))}\n");
        }
Exemplo n.º 2
0
        public async Task TestParallelQuickSort()
        {
            var qs = new ParallelQuickSorter <int>();

            for (int i = 70; i <= 100; i += 10)
            {
                Console.WriteLine($"InsertionBound = {i}");

                var tasks = new Task <TimeSpan> [5];

                for (int j = 0; j < 5; j++)
                {
                    tasks[j] = Task.Run(() => QuickSortRoutine(qs));
                }

                await Task.WhenAll(tasks);

                Yellow.WriteLine(
                    $"Average time is {new TimeSpan(Convert.ToInt64(tasks.Average(task => task.Result.Ticks)))}\n");
            }
        }