Beispiel #1
0
        private static void RunLinpack()
        {
            var problems   = Enumerable.Range(1, 12).Select(n => MatrixSummer.Setup((int)Math.Pow(2, n))).ToArray();
            var linpackSeq = new McCollinRunner <long[, ], long>(MatrixSummer.SumSeq, problems);
            var linpackMR  = new McCollinRunner <long[, ], long>(MatrixSummer.SumMapReduce, problems);
            var linpackP   = new McCollinRunner <long[, ], long>(MatrixSummer.SumParallel, problems);
            var linpackT   = new McCollinRunner <long[, ], Task <long> >(MatrixSummer.SumTask, problems);

            linpackSeq.Run(100, m => m.GetLength(0));
            linpackMR.Run(100, m => m.GetLength(0));
            linpackP.Run(100, m => m.GetLength(0));
            linpackT.Run(100, m => m.GetLength(0));

            const string fileName = "linpack.csv";

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            var f = new StreamWriter(fileName);

            f.WriteLine("Problem Size,Sequential,Sequential Error,Map Reduce,Map Reduce Error,Parallel Foreach,Parallel Foreach Error, Tasks, Tasks Error");

            foreach (var res in linpackSeq.Results)
            {
                var mr = linpackMR.Results[res.Key];
                var p  = linpackP.Results[res.Key];
                var t  = linpackT.Results[res.Key];
                f.WriteLine($"{res.Key},{res.Value.Mean},{res.Value.StandardDeviation},{mr.Mean},{mr.StandardDeviation},{p.Mean},{p.StandardDeviation},{t.Mean},{t.StandardDeviation}");
            }

            f.Flush();
            f.Close();
        }
Beispiel #2
0
        private static void RunSummation()
        {
            var problems = Enumerable.Range(1, BenchmarkTreeSize).Select(n => TreeGenerator.CreateBinaryTree(n, () => Rnd.Next(int.MinValue, int.MaxValue))).ToArray();
            var sumSeq   = new McCollinRunner <Tree <int>, int>(TreeSummer.SumLeaves, problems);
            var sumFJ    = new McCollinRunner <Tree <int>, Task <int> >(TreeSummer.SumLeavesForkJoin, problems);
            var sumL     = new McCollinRunner <Task <Tree <int> >, Task <int> >(TreeSummer.SumLeavesLenient, problems.Select(t => Task.FromResult(t)).ToArray());

            sumSeq.Run(100, m => m.NumberOfLeaves);
            sumFJ.Run(100, m => m.NumberOfLeaves);
            sumL.Run(100, m => m.Result.NumberOfLeaves);

            const string fileName = "summation.csv";

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            var f = new StreamWriter(fileName);

            f.WriteLine("Problem Size,Sequential,Sequential Error,Fork Join,Fork Join Error,Lenient,Lenient Error");

            foreach (var res in sumSeq.Results)
            {
                var fj = sumFJ.Results[res.Key];
                var l  = sumL.Results[res.Key];
                f.WriteLine($"{res.Key},{res.Value.Mean},{res.Value.StandardDeviation},{fj.Mean},{fj.StandardDeviation},{l.Mean},{l.StandardDeviation}");
            }

            f.Flush();
            f.Close();
        }