Code Monkey home page Code Monkey logo

Comments (5)

dmah42 avatar dmah42 commented on June 26, 2024 1

can you share what you've tried?

from benchmark.

dmah42 avatar dmah42 commented on June 26, 2024

benchmarks using fixtures expect to be registered using BENCHMARK_REGISTER_F.

you could probably go through the macros and figure out what the callable ends up being. ie, BENCHMARK_REGISTER_F calls RegisterBenchmarkInternal(new FixtureClass_MethodName_Method()) essentially, so something like RegisterBenchmark("my_bm", FixtureClass_MethodName_Method, args) might get you close... but it's probably easier to stick with the macro registration.

from benchmark.

ahmednofal avatar ahmednofal commented on June 26, 2024

I wish I could do it using the macro, but I need to take in arguments from the user and configure the Args of the benchmark with those inputs programmatically. I tried your approach, but I am not sure I am doing it correctly, can you please give a full code example, if it is not too much trouble.

Thank you very much for response.

from benchmark.

ahmednofal avatar ahmednofal commented on June 26, 2024

Of course, sorry for not posting it at first.

BENCHMARK_DEFINE_F(FixtureClassName, BM_Func)
(::benchmark::State& state) {
  for (auto _ : state) {
     [..... bench logic here .....]
  }
}

int main(int argc, char** argv){
  // Some arg parsing logic here (verified to work just fine)
  benchmark::Initialize(&rem_argv_len, rem_argv_c.data());
  benchmark::RegisterBenchmark("SomeArbitraryName", FixtureClassName_BM_Func_Benchmark)->Arg(0); // checked what the macro resolved to and it puts "_Benchmark" at the end and passing here dummy 0 in Arg but it represents what I would like to do
  benchmark::RunSpecifiedBenchmarks();
  benchmark::Shutdown();
}

This does not compile.
Thank you greatly for responding :)

from benchmark.

dmah42 avatar dmah42 commented on June 26, 2024

working on this as i get bits of time. i'll post progress here as maybe you can figure it out before i do.

the preprocessor output includes

class FixtureClass : public benchmark::Fixture {
 public:
  void SetUp(const ::benchmark::State& state) override {}
  void TearDown(const ::benchmark::State& state) override {}
};

class FixtureClass_BM_Func_Benchmark : public FixtureClass {
 public:
  FixtureClass_BM_Func_Benchmark() { this->SetName("FixtureClass" "/" "BM_Func"); }
 protected:
  void BenchmarkCase(::benchmark::State&)         override; };
  void FixtureClass_BM_Func_Benchmark::BenchmarkCase(::benchmark::State& state) {
    int i = 0;
    for (auto _ : state) {
      benchmark::DoNotOptimize(i += 1);
    }
  }

static ::benchmark::internal::Benchmark* benchmark_uniq_2FixtureClass_BM_Func_Benchmark __attribute__((unused)) =
  (::benchmark::internal::RegisterBenchmarkInternal(new FixtureClass_BM_Func_Benchmark()))->Arg(0);

from benchmark.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.