0

The benchmarked code requires some input. I have gathered the data in several files. I would like to run the benchmark like this:

./benchmark file1.txt file2.txt file3.txt

The files should be then used as input to the benchmarked code. In my particular usecase, I have a set of benchmarks. The set of benchmarks should be run for every file specified in the command line.

Although I would prefer this to be handled by command line arguments like shown above, I accept any working solution that would allow passing files to the benchmarks.

I am new to Google benchmarks and I see no way to do such thing because the benchmark executable doesn't accept user data. The closest thing to this I have found in to documentation is https://github.com/google/benchmark/blob/main/docs/user_guide.md#using-register-benchmark but I still have to pass argc and argv to benchmark::Initialize.

I could theoretically make my argument parsing which would accept files and would be compatible with Google benchmark executable's arguments and then make a modified version of argc and argv for benchmark::Initialize which would contain benchmark arguments but not the files. But this is a exaggeratedly complicated solution. And Google benchmarks probably expects the argc and argv to be the actual argc and argv of the program which could break it (for example some libraries I have used which provide their own main have a special mechanism for handling Windows' arguments which could somehow conflict with this).

Questions

How am I supposed to run benchmarks which require files? Is that forbidden/not the intended use case of Google benchmark? Am I expected to hardcode the paths? I'm surely not the only one who wants to use files in benchmarks. Is passing external data to benchmarks undesired?

user13840624
  • 133
  • 8
  • This post is a duplicate of the linked post, but none of the answers in the other post aren't applicable for my problem. The outlined solutions work for numbers only, not strings of filenames. – user13840624 Aug 10 '23 at 20:55
  • 1
    I think I have found a potential solution for this problem. I will direct my attention at https://stackoverflow.com/questions/51519376/how-to-pass-arguments-to-a-google-benchmark-program and leave this question as is. – user13840624 Aug 10 '23 at 21:16

0 Answers0