Adjusted timing test repetition and added QR decomposition #6

Merged
Cynopolis merged 3 commits from Minor-cicd-fixes into main 2025-06-10 23:06:03 +00:00
2 changed files with 53 additions and 65 deletions

View File

@@ -8,6 +8,7 @@
// any other libraries // any other libraries
#include <array> #include <array>
#include <cmath> #include <cmath>
#include <cstdint>
// basically re-run all of the matrix tests with huge matrices and time the // basically re-run all of the matrix tests with huge matrices and time the
// results. // results.
@@ -29,13 +30,13 @@ TEST_CASE("Timing Tests", "Matrix") {
Matrix<4, 4> mat5{}; Matrix<4, 4> mat5{};
SECTION("Addition") { SECTION("Addition") {
for (uint32_t i{0}; i < 10000; i++) { for (uint32_t i{0}; i < 100000; i++) {
mat3 = mat1 + mat2; mat3 = mat1 + mat2;
} }
} }
SECTION("Subtraction") { SECTION("Subtraction") {
for (uint32_t i{0}; i < 10000; i++) { for (uint32_t i{0}; i < 100000; i++) {
mat3 = mat1 - mat2; mat3 = mat1 - mat2;
} }
} }
@@ -47,19 +48,19 @@ TEST_CASE("Timing Tests", "Matrix") {
} }
SECTION("Scalar Multiplication") { SECTION("Scalar Multiplication") {
for (uint32_t i{0}; i < 10000; i++) { for (uint32_t i{0}; i < 100000; i++) {
mat3 = mat1 * 3; mat3 = mat1 * 3;
} }
} }
SECTION("Element Multiply") { SECTION("Element Multiply") {
for (uint32_t i{0}; i < 10000; i++) { for (uint32_t i{0}; i < 100000; i++) {
mat1.ElementMultiply(mat2, mat3); mat1.ElementMultiply(mat2, mat3);
} }
} }
SECTION("Element Divide") { SECTION("Element Divide") {
for (uint32_t i{0}; i < 10000; i++) { for (uint32_t i{0}; i < 100000; i++) {
mat1.ElementDivide(mat2, mat3); mat1.ElementDivide(mat2, mat3);
} }
} }
@@ -68,52 +69,59 @@ TEST_CASE("Timing Tests", "Matrix") {
// what about matrices of 0,0 or 1,1? // what about matrices of 0,0 or 1,1?
// minor matrix for 2x2 matrix // minor matrix for 2x2 matrix
Matrix<49, 49> minorMat1{}; Matrix<49, 49> minorMat1{};
for (uint32_t i{0}; i < 10000; i++) { for (uint32_t i{0}; i < 100000; i++) {
mat1.MinorMatrix(minorMat1, 0, 0); mat1.MinorMatrix(minorMat1, 0, 0);
} }
} }
SECTION("Determinant") { SECTION("Determinant") {
for (uint32_t i{0}; i < 100000; i++) { for (uint32_t i{0}; i < 1000000; i++) {
float det1 = mat4.Det(); float det1 = mat4.Det();
} }
} }
SECTION("Matrix of Minors") { SECTION("Matrix of Minors") {
for (uint32_t i{0}; i < 100000; i++) { for (uint32_t i{0}; i < 1000000; i++) {
mat4.MatrixOfMinors(mat5); mat4.MatrixOfMinors(mat5);
} }
} }
SECTION("Invert") { SECTION("Invert") {
for (uint32_t i{0}; i < 100000; i++) { for (uint32_t i{0}; i < 1000000; i++) {
mat5 = mat4.Invert(); mat5 = mat4.Invert();
} }
}; };
SECTION("Transpose") { SECTION("Transpose") {
for (uint32_t i{0}; i < 10000; i++) { for (uint32_t i{0}; i < 100000; i++) {
mat3 = mat1.Transpose(); mat3 = mat1.Transpose();
} }
} }
SECTION("Normalize") { SECTION("Normalize") {
for (uint32_t i{0}; i < 10000; i++) { for (uint32_t i{0}; i < 100000; i++) {
mat3 = mat1 / mat1.EuclideanNorm(); mat3 = mat1 / mat1.EuclideanNorm();
} }
} }
SECTION("GET ROW") { SECTION("GET ROW") {
Matrix<1, 50> mat1Rows{}; Matrix<1, 50> mat1Rows{};
for (uint32_t i{0}; i < 1000000; i++) { for (uint32_t i{0}; i < 100000000; i++) {
mat1.GetRow(0, mat1Rows); mat1.GetRow(0, mat1Rows);
} }
} }
SECTION("GET COLUMN") { SECTION("GET COLUMN") {
Matrix<50, 1> mat1Columns{}; Matrix<50, 1> mat1Columns{};
for (uint32_t i{0}; i < 1000000; i++) { for (uint32_t i{0}; i < 100000000; i++) {
mat1.GetColumn(0, mat1Columns); mat1.GetColumn(0, mat1Columns);
} }
} }
SECTION("QR Decomposition") {
Matrix<50, 50> Q, R{};
for (uint32_t i{0}; i < 500; i++) {
mat1.QRDecomposition(Q, R);
}
}
} }

View File

@@ -1,56 +1,36 @@
Randomness seeded to: 2444679151 Running matrix-timing-tests with timing
0.180 s: Addition Randomness seeded to: 3567651885
0.180 s: Timing Tests 1.857 s: Addition
0.177 s: Subtraction 1.857 s: Timing Tests
0.177 s: Timing Tests 1.788 s: Subtraction
1.868 s: Multiplication 1.788 s: Timing Tests
1.868 s: Timing Tests 1.929 s: Multiplication
0.127 s: Scalar Multiplication 1.929 s: Timing Tests
0.127 s: Timing Tests 1.268 s: Scalar Multiplication
0.173 s: Element Multiply 1.268 s: Timing Tests
0.173 s: Timing Tests 1.798 s: Element Multiply
0.178 s: Element Divide 1.798 s: Timing Tests
0.178 s: Timing Tests 1.802 s: Element Divide
0.172 s: Minor Matrix 1.803 s: Timing Tests
0.172 s: Timing Tests 1.553 s: Minor Matrix
0.103 s: Determinant 1.554 s: Timing Tests
0.103 s: Timing Tests 1.009 s: Determinant
0.411 s: Matrix of Minors 1.009 s: Timing Tests
0.411 s: Timing Tests 4.076 s: Matrix of Minors
0.109 s: Invert 4.076 s: Timing Tests
0.109 s: Timing Tests 1.066 s: Invert
0.122 s: Transpose 1.066 s: Timing Tests
0.122 s: Timing Tests 1.246 s: Transpose
0.190 s: Normalize 1.246 s: Timing Tests
0.190 s: Timing Tests 2.284 s: Normalize
0.006 s: GET ROW 2.284 s: Timing Tests
0.006 s: Timing Tests 0.606 s: GET ROW
0.235 s: GET COLUMN 0.606 s: Timing Tests
0.235 s: Timing Tests 24.629 s: GET COLUMN
24.630 s: Timing Tests
3.064 s: QR Decomposition
3.064 s: Timing Tests
=============================================================================== ===============================================================================
test cases: 1 | 1 passed test cases: 1 | 1 passed
assertions: - none - assertions: - none -
Command being timed: "build/unit-tests/matrix-timing-tests -d yes"
User time (seconds): 4.05
System time (seconds): 0.00
Percent of CPU this job got: 100%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:04.05
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 3200
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 184
Minor (reclaiming a frame) page faults: 171
Voluntary context switches: 1
Involuntary context switches: 26
Swaps: 0
File system inputs: 12
File system outputs: 1
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0