Пример #1
0
    private static void Main()
    {
        SumCounter.SequentialFor(ItemCount);
        SumCounter.ParallelFor(ItemCount);
        SumCounter.ParallelForEach(ItemCount);

        Console.WriteLine("Measuring {0} counts", LoopCount);
        ParallelTime.Run(NofTasks, LoopCount / NofTasks);

        ParallelExceptions.Run();
        CustomPartitioner.Run();
    }
Пример #2
0
        public double RunParallelSort(int threadsCount)
        {
            this.Array = this.SourceArray.Clone() as T[];
            int end;
            int begin = 0;

            for (int i = 0; i < threadsCount; i++)
            {
                end = (i + 1) * this.Array.Length / threadsCount + (i == threadsCount - 1 ? -1 : 0);
                this.CreateThread(begin, end);
                begin = end + 1;
            }

            ParallelTime.Start();

            this.Threads.ForEach(x => x.Start());
            this.Threads.ForEach(x => x.Join());

            this.MergeSort(this.Array, 0, this.Array.Length - 1);
            ParallelTime.Stop();
            return(ParallelTime.ElapsedMilliseconds / 1e3);
        }