I want to modify a templated google benchmark (with custom arguments) to run with a test fixture class, but don't know if this is really possible and if so, how the correct syntax is.
Just adding the fixture class doesn't seem to be enough.
static void CustomArguments(benchmark::internal::Benchmark* b) {
// define I, J
for (auto i : I)
{
for (auto j : J)
b->Args({i, j});
}
}
template<typename my_type>
class My_Fixture : public benchmark::Fixture
{
protected:
void SetUp(const ::benchmark::State& state) { ...}
virtual void TearDown() { ...}
};
template <typename any_type>
static void insert(benchmark::State& state)
{
for (auto _ : state)
{ ...}
}
BENCHMARK_TEMPLATE_F(My_Fixture, insert, my_type)->Apply(CustomArguments);
BENCHMARK_MAIN();
The compiler complains about the before-last code line
error: expected initializer before '->' token
, but also fails to find the variable declarations from the fixture inside the test. This might be a consequence or an additional error. Do I need to register the fixture additionally? The example is running perfectly without fixture.