// See https://aka.ms/new-console-template for more information using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Running; using ConsoleApp1; BenchmarkRunner.Run(); //var matrixService = new MatrixService(); //var testArr1 = new int[3, 3] //{ // {5, 1, 6 }, // {-1, 7, 9 }, // {-8, 2, 3 }, //}; //var testArr2 = new int[3, 3] //{ // {8, 1, 4 }, // {5, -5, 7 }, // {-3, -2, 7 }, //}; //var result = matrixService.MultiplicationMatrix(testArr1, testArr2, 12); //for(int i = 0; i < result.GetLength(0); i++) //{ // for (int j = 0; j < result.GetLength(1); j++) // { // Console.Write(result[i, j] + " "); // } // Console.WriteLine(); //} [MemoryDiagnoser] public class MatrixTest { int[,] firstMatrix100; int[,] secondMatrix100; int[,] firstMatrix300; int[,] secondMatrix300; int[,] firstMatrix500; int[,] secondMatrix500; MatrixService matrixService; public MatrixTest() { matrixService = new MatrixService(); firstMatrix100 = matrixService.RandomGenerateMatrix(100); secondMatrix100 = matrixService.RandomGenerateMatrix(100); firstMatrix300 = matrixService.RandomGenerateMatrix(300); secondMatrix300 = matrixService.RandomGenerateMatrix(300); firstMatrix500 = matrixService.RandomGenerateMatrix(500); secondMatrix500 = matrixService.RandomGenerateMatrix(500); } [Benchmark] public int[,] MultiplicationMatrix100MonoThread() { return matrixService.MultiplicationMatrix(firstMatrix100, secondMatrix100, 1); } [Benchmark] public int[,] MultiplicationMatrix100MultiThread() { return matrixService.MultiplicationMatrix(firstMatrix100, secondMatrix100, 12); } [Benchmark] public int[,] MultiplicationMatrix300MonoThread() { return matrixService.MultiplicationMatrix(firstMatrix300, secondMatrix300, 1); } [Benchmark] public int[,] MultiplicationMatrix300MultiThread() { return matrixService.MultiplicationMatrix(firstMatrix300, secondMatrix300, 12); } [Benchmark] public int[,] MultiplicationMatrix500MonoThread() { return matrixService.MultiplicationMatrix(firstMatrix500, secondMatrix500, 1); } [Benchmark] public int[,] MultiplicationMatrix500MultiThread() { return matrixService.MultiplicationMatrix(firstMatrix500, secondMatrix500, 12); } }