Closed r-devulap closed 1 year ago
Personally, i usually do
#define tmp(x) BENCHMARK_CAPTURE(mybench<int64_t>, random, 10000, std::string(x))
tmp("foo");
tmp("bar");
tmp("baz");
if that is what you mean?
umm no. I meant I want to combine passing arbitrary arguments with templates. Something like this:
BENCHMARK_CAPTURE(mybench<int64_t>, random, 10000, std::string("random"));
BENCHMARK_CAPTURE(mybench<uint64_t>, random, 10000, std::string("random"));
BENCHMARK_CAPTURE(mybench<double>, random, 10000, std::string("random"));
Oh, i see. Well, e.g. you could just copy-paste BENCHMARK_CAPTURE
and make it do your bidding:
https://godbolt.org/z/ncsWevP88
MY_BENCHMARK_CAPTURE(mybench, int64_t, random, 10000, std::string("random"));
MY_BENCHMARK_CAPTURE(mybench, double, random, 10000, std::string("random"));
Thanks! While that works, the problem is that the benchmark names for the two declared above will be the same for tboth of them: mybench/random
which won't work with filtering or comparison, right?
never mind, that's fixable. thanks :D
Right, but the name already needs to explicitly disambiguate the rest of the arguments, so just also deal with that extra template argument? You could of course sink that into the macro: https://godbolt.org/z/TErcbsYcM
My C++ isn't the best so this might be an obvious thing but how do I templatize a benchmark that uses BENCHMARK_CAPTURE? Something like this: