mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Migrate Eigen benchmarks to the Google benchmark framework
libeigen/eigen!2132 Closes #3025 Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
30
benchmarks/bench_reverse.cpp
Normal file
30
benchmarks/bench_reverse.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <benchmark/benchmark.h>
|
||||
#include <Eigen/Core>
|
||||
|
||||
using namespace Eigen;
|
||||
|
||||
static void BM_MatrixReverse(benchmark::State& state) {
|
||||
int n = state.range(0);
|
||||
typedef Matrix<double, Dynamic, Dynamic> MatrixType;
|
||||
MatrixType a = MatrixType::Random(n, n);
|
||||
MatrixType b(n, n);
|
||||
for (auto _ : state) {
|
||||
b = a.reverse();
|
||||
benchmark::DoNotOptimize(b.data());
|
||||
}
|
||||
state.SetBytesProcessed(state.iterations() * n * n * sizeof(double));
|
||||
}
|
||||
BENCHMARK(BM_MatrixReverse)->RangeMultiplier(2)->Range(4, 512);
|
||||
|
||||
static void BM_VectorReverse(benchmark::State& state) {
|
||||
int n = state.range(0);
|
||||
typedef Matrix<double, Dynamic, 1> VectorType;
|
||||
VectorType a = VectorType::Random(n);
|
||||
VectorType b(n);
|
||||
for (auto _ : state) {
|
||||
b = a.reverse();
|
||||
benchmark::DoNotOptimize(b.data());
|
||||
}
|
||||
state.SetBytesProcessed(state.iterations() * n * sizeof(double));
|
||||
}
|
||||
BENCHMARK(BM_VectorReverse)->RangeMultiplier(4)->Range(16, 1 << 18);
|
||||
Reference in New Issue
Block a user