From 791e3b2313ddbdd145ad36e353b85327416645c0 Mon Sep 17 00:00:00 2001 From: Orange Date: Wed, 17 Sep 2025 20:40:03 +0300 Subject: [PATCH] improved bench --- benchmark/benchmark_mat.cpp | 51 ++++++++++++++++++++++++++++++++----- benchmark/main.cpp | 5 ++++ 2 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 benchmark/main.cpp diff --git a/benchmark/benchmark_mat.cpp b/benchmark/benchmark_mat.cpp index 85d303e..f2eda9a 100644 --- a/benchmark/benchmark_mat.cpp +++ b/benchmark/benchmark_mat.cpp @@ -5,12 +5,10 @@ #include #include -#include - using namespace omath; -void mat_multiplication(benchmark::State& state) +void mat_float_multiplication_col_major(benchmark::State& state) { using MatType = Mat<128, 128, float, MatStoreType::COLUMN_MAJOR>; MatType a; @@ -20,10 +18,49 @@ void mat_multiplication(benchmark::State& state) for (auto _ : state) - { std::ignore = a * b; - } +} +void mat_float_multiplication_row_major(benchmark::State& state) +{ + using MatType = Mat<128, 128, float, MatStoreType::ROW_MAJOR>; + MatType a; + MatType b; + a.set(3.f); + b.set(7.f); + + + for (auto _ : state) + std::ignore = a * b; } -BENCHMARK(mat_multiplication); -BENCHMARK_MAIN(); \ No newline at end of file +void mat_double_multiplication_row_major(benchmark::State& state) +{ + using MatType = Mat<128, 128, double, MatStoreType::ROW_MAJOR>; + MatType a; + MatType b; + a.set(3.f); + b.set(7.f); + + + for (auto _ : state) + std::ignore = a * b; +} + +void mat_double_multiplication_col_major(benchmark::State& state) +{ + using MatType = Mat<128, 128, double, MatStoreType::COLUMN_MAJOR>; + MatType a; + MatType b; + a.set(3.f); + b.set(7.f); + + + for (auto _ : state) + std::ignore = a * b; +} + +BENCHMARK(mat_float_multiplication_col_major)->Iterations(5000); +BENCHMARK(mat_float_multiplication_row_major)->Iterations(5000); + +BENCHMARK(mat_double_multiplication_col_major)->Iterations(5000); +BENCHMARK(mat_double_multiplication_row_major)->Iterations(5000); \ No newline at end of file diff --git a/benchmark/main.cpp b/benchmark/main.cpp new file mode 100644 index 0000000..790aeae --- /dev/null +++ b/benchmark/main.cpp @@ -0,0 +1,5 @@ +// +// Created by Vlad on 9/17/2025. +// +#include +BENCHMARK_MAIN(); \ No newline at end of file