Ejemplo n.º 1
0
        private static void RunTuple(bool firstRun)
        {
            void TupleCalc(Tuple <int, int> range)
            {
                for (int i = range.Item1; i < range.Item2; i++)
                {
                    arrayTuple[i] = Math.Pow(i, 2);
                }
            }

            stopwatch.Restart();

            ParallelRunner.Run(TupleCalc, arrayTuple.Length);

            if (!firstRun)
            {
                sumTuple += stopwatch.ElapsedTicks;
            }
            File.AppendAllText("log.txt", "Tuple: " + stopwatch.ElapsedTicks + Environment.NewLine);
        }
Ejemplo n.º 2
0
        private static void RunDelegate(bool firstRun)
        {
            Action DelegateCalc(Tuple <int, int> range)
            {
                return(() =>
                {
                    for (int i = range.Item1; i < range.Item2; i++)
                    {
                        arrayDelegate[i] = Math.Pow(i, 2);
                    }
                });
            }

            stopwatch.Restart();

            ParallelRunner.Run(DelegateCalc, arrayDelegate.Length);

            if (!firstRun)
            {
                sumDelegate += stopwatch.ElapsedTicks;
            }
            File.AppendAllText("log.txt", "Delegate: " + stopwatch.ElapsedTicks + Environment.NewLine);
        }