mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
improved bench
This commit is contained in:
@@ -5,12 +5,10 @@
|
|||||||
|
|
||||||
#include <omath/omath.hpp>
|
#include <omath/omath.hpp>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <print>
|
|
||||||
|
|
||||||
using namespace omath;
|
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>;
|
using MatType = Mat<128, 128, float, MatStoreType::COLUMN_MAJOR>;
|
||||||
MatType a;
|
MatType a;
|
||||||
@@ -20,10 +18,49 @@ void mat_multiplication(benchmark::State& state)
|
|||||||
|
|
||||||
|
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
|
||||||
std::ignore = a * b;
|
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);
|
void mat_double_multiplication_row_major(benchmark::State& state)
|
||||||
BENCHMARK_MAIN();
|
{
|
||||||
|
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);
|
||||||
5
benchmark/main.cpp
Normal file
5
benchmark/main.cpp
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
//
|
||||||
|
// Created by Vlad on 9/17/2025.
|
||||||
|
//
|
||||||
|
#include <benchmark/benchmark.h>
|
||||||
|
BENCHMARK_MAIN();
|
||||||
Reference in New Issue
Block a user