83 lines
1.8 KiB
C#
83 lines
1.8 KiB
C#
using BenchmarkDotNet.Attributes;
|
|
using BenchmarkDotNet.Running;
|
|
using ConsoleApp1;
|
|
|
|
BenchmarkRunner.Run<MatrixTest>();
|
|
|
|
//var matrixService = new MatrixService();
|
|
|
|
//var matrix = matrixService.RandomGenerateMatrix(3);
|
|
|
|
//for(int i = 0; i < matrix.GetLength(0); i++)
|
|
//{
|
|
// for (int j = 0; j < matrix.GetLength(0); j++)
|
|
// {
|
|
// Console.Write(matrix[i, j] + " ");
|
|
// }
|
|
// Console.WriteLine();
|
|
//}
|
|
|
|
//var result1 = matrixService.DeterminantOfMatrix(matrix, 1);
|
|
//var result2 = matrixService.DeterminantOfMatrix(matrix, 12);
|
|
|
|
//Console.WriteLine(result1);
|
|
//Console.WriteLine(result2);
|
|
//Console.ReadLine();
|
|
|
|
[MemoryDiagnoser]
|
|
public class MatrixTest
|
|
{
|
|
double[,] Matrix5;
|
|
double[,] Matrix8;
|
|
double[,] Matrix11;
|
|
|
|
|
|
MatrixService matrixService;
|
|
|
|
|
|
public MatrixTest()
|
|
{
|
|
matrixService = new MatrixService();
|
|
|
|
Matrix5 = matrixService.RandomGenerateMatrix(5);
|
|
Matrix8 = matrixService.RandomGenerateMatrix(8);
|
|
Matrix11 = matrixService.RandomGenerateMatrix(11);
|
|
|
|
}
|
|
|
|
[Benchmark]
|
|
public double MatrixDeterminant5()
|
|
{
|
|
return matrixService.DeterminantOfMatrix(Matrix5, 1);
|
|
}
|
|
|
|
[Benchmark]
|
|
public double MatrixDeterminantParallel5()
|
|
{
|
|
return matrixService.DeterminantOfMatrix(Matrix5, 12);
|
|
}
|
|
|
|
[Benchmark]
|
|
public double MatrixDeterminant8()
|
|
{
|
|
return matrixService.DeterminantOfMatrix(Matrix8, 1);
|
|
}
|
|
|
|
[Benchmark]
|
|
public double MatrixDeterminantParallel8()
|
|
{
|
|
return matrixService.DeterminantOfMatrix(Matrix8, 12);
|
|
}
|
|
|
|
[Benchmark]
|
|
public double MatrixDeterminant11()
|
|
{
|
|
return matrixService.DeterminantOfMatrix(Matrix11, 1);
|
|
}
|
|
|
|
[Benchmark]
|
|
public double MatrixDeterminantParallel11()
|
|
{
|
|
return matrixService.DeterminantOfMatrix(Matrix11, 12);
|
|
}
|
|
} |