コード例 #1
0
        private static async Task GenerateMatrixesPeriodically()
        {
            for (int i = 0; i < matrixCount; i++)
            {
                Matrix item = MatrixGenerator.GenerateMatrix(matrixSize);

                toCalculate.TryAdd(item);
            }
        }
コード例 #2
0
        private static void ListOfMatrixesMultiplication()
        {
            var processingTimes = new Dictionary <string, TimeSpan>();
            var m1       = MatrixGenerator.GenerateMatrix(matrixSize);
            var matrixes = Enumerable.Range(0, 20)
                           .Select(_ => MatrixGenerator.GenerateMatrix(matrixSize))
                           .ToList();

            var baseTime = Measure(() => MultiplyAll(m1, matrixes));

            processingTimes["Parallel Foreach"] = Measure(() => MultiplyAllParallel(m1, matrixes));
            processingTimes["Plinq"]            = Measure(() => MultiplyAllPlinq(m1, matrixes));

            PrintSpeedup(baseTime, processingTimes);
        }
コード例 #3
0
        private static void TwoMatrixesMultiplication()
        {
            var processingTimes = new Dictionary <string, TimeSpan>();
            var m1 = MatrixGenerator.GenerateMatrix(matrixSize);
            var m2 = MatrixGenerator.GenerateMatrix(matrixSize);

            var baseTime = Measure(() => m1.Multiply(m2));

            processingTimes["Parallel Rows"]            = Measure(() => m1.MultiplyParallelRows(m2));
            processingTimes["Parallel RowsCols"]        = Measure(() => m1.MultiplyParallelRowsCols(m2));
            processingTimes["Parallel Cols"]            = Measure(() => m1.MultiplyParallelCols(m2));
            processingTimes["Prallel Rows Manual"]      = Measure(() => m1.MultiplyParallelRowManual(m2));
            processingTimes["Prallel Rows Thread Pool"] = Measure(() => m1.MultiplyParallelRowManualThreadPool(m2));

            PrintSpeedup(baseTime, processingTimes);
        }