Commit 25297946 authored by Damien L-G's avatar Damien L-G

Add comparison of construction of spline object against raw GSL to benchmark

parent eb2f3132
......@@ -95,4 +95,53 @@ static void BM_EvalRawGSL(benchmark::State &state) {
}
BENCHMARK(BM_EvalRawGSL);
int const nx = 200;
int const ny = 200;
std::vector<double> iota_vector(size_t n, double val = 0.) {
std::vector<double> v(n);
std::iota(v.begin(), v.end(), val);
return v;
}
static void BM_ConstructSpline2D(benchmark::State &state) {
for (auto _ : state) {
auto const x = iota_vector(nx);
auto const y = iota_vector(ny);
std::vector<double> const z(nx * ny);
Spline2D<Bicubic> spline(x, y, z);
}
}
BENCHMARK(BM_ConstructSpline2D);
static void BM_ConstructSpline2DMoveArrays(benchmark::State &state) {
for (auto _ : state) {
auto x = iota_vector(nx);
auto y = iota_vector(ny);
std::vector<double> z(nx * ny);
Spline2D<Bicubic> spline(std::move(x), std::move(y), std::move(z));
}
}
BENCHMARK(BM_ConstructSpline2DMoveArrays);
static void BM_ConstructRawGSL(benchmark::State &state) {
auto const x = iota_vector(nx);
auto const y = iota_vector(ny);
std::vector<double> const z(nx * ny);
for (auto _ : state) {
auto *spline = gsl_interp2d_alloc(gsl_interp2d_bicubic, x.size(), y.size());
gsl_interp2d_init(spline, x.data(), y.data(), z.data(), x.size(), y.size());
gsl_interp2d_free(spline);
}
}
BENCHMARK(BM_ConstructRawGSL);
static void BM_ConstructArraysOnly(benchmark::State &state) {
for (auto _ : state) {
auto const x = iota_vector(nx);
auto const y = iota_vector(ny);
std::vector<double> const z(nx * ny);
}
}
BENCHMARK(BM_ConstructArraysOnly);
BENCHMARK_MAIN();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment