0

Hi I am trying to set the following Google Benchmark fixture property in the class. But it seems like the property is not getting set correctly. Ex:

class Foo : public benchmark::Fixture {
Foo(){
  this->Iterations(10);
}

// or 
void SetUp(benchmark::State& state) override {
  this->Iterations(10);
}
}

Both didn't seem to be working. But The following works without a problem.

class Foo : public benchmark::Fixture {
...
}
BENCHMARK_DEFINE_F(Foo, foo_run)(benchmark::State& st) {
...
}
BENCHMARK_REGISTER_F(Foo, foo_run)->Iterations(10);

What could be the issue here? Does the macro override my values with default values?

n1r44
  • 581
  • 1
  • 4
  • 12
  • i believe that by the time the fixture ctor or Setup have been called, the iterations have already been red and stored elsewhere as you're basically in the runloop by then. i agree it seems like this should work but it's not the intended use of Fixtures, which is to allow you to do your setup outside the timed function. it may be worth opening an issue on the repository :) – dma Jan 23 '23 at 11:08

0 Answers0