I want to run a google/benchmark on float, double and long double.
Given the BENCHMARK_TEMPLATE example, I attempted the following:
#include <cmath>
#include <ostream>
#include <random>
#include <benchmark/benchmark.h>
template<typename Real>
BM_PowTemplated(benchmark::State& state) {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_real_distribution<Real> dis(1, 10);
auto s = dis(gen);
auto t = dis(gen);
Real y;
while (state.KeepRunning()) {
benchmark::DoNotOptimize(y = std::pow(s, t));
}
std::ostream cnull(0);
cnull << y;
}
BENCHMARK_TEMPLATE(BM_PowTemplated, float, double, long double);
BENCHMARK_MAIN();
I imagined that this would then create three benchmarks for float, double and long double, but instead it doesn't compile!
What is the proper syntax for creating templated google benchmarks? Is my mental model for how BENCHMARK_TEMPLATE should work correct and if so how can I fix this code?
Aucun commentaire:
Enregistrer un commentaire