Naming Google Benchmark values

85 Views Asked by At

I feel like I'm missing something obvious, but, is there a way to name Google Benchmark argument values?

----------------               ----------
Benchmark                      Benchmark
----------------               ----------
NameTest/Alex      instead of  NameTest/0
NameTest/Bob                   NameTest/1
NameTest/Charles               NameTest/2

for a benchmark defined something like this:

inline constexpr auto names = std::array{ "Alex", "Bob", "Charles" };

static void NameTest(benchmark::State& state)
{
    const auto name = names[state.range(0)];
}
BENCHMARK(NameTest)->DenseRange(0, names.size() - 1);
1

There are 1 best solutions below

0
On

you can call SetLabel on the State object that is passed in.