あなたはと間違った方法でBENCHMARK_TEMPLATE
を使用し、あなたの
BENCHMARK_TEMPLATE(BM_PowTemplated, float, double, long double);
https://github.com/google/benchmark/のreadmeファイルには、
template <class Q> int BM_Sequential(benchmark::State& state) { .. }
BENCHMARK_TEMPLATE(BM_Sequential, WaitQueue<int>)->Range(1<<0, 1<<10);
Three macros are provided for adding benchmark templates.
#define BENCHMARK_TEMPLATE(func, ...) // Takes any number of parameters.
#define BENCHMARK_TEMPLATE1(func, arg1)
#define BENCHMARK_TEMPLATE2(func, arg1, arg2)
だから、ARG1とBENCHMARK_TEMPLATE
はARG1とARG2と、1つのテンプレートパラメータを持つ関数のために使用されていると言います2つのテンプレートパラメータを持つ関数の場合BM_PowTemplated
には1つのパラメータしかないので、BENCHMARK_TEMPLATE
に3つの引数を使用することはできません。例えばグーグル/ベンチマークの
チェックtest/cxx03_test.cc
:https://github.com/google/benchmark/blob/b2e734087532897b7bb4c51a6b4f503060c9a20f/test/cxx03_test.cc
template <class T, class U>
void BM_template2(benchmark::State& state) {
BM_empty(state);
}
BENCHMARK_TEMPLATE2(BM_template2, int, long);
template <class T>
void BM_template1(benchmark::State& state) {
BM_empty(state);
}
BENCHMARK_TEMPLATE(BM_template1, long);
BENCHMARK_TEMPLATE1(BM_template1, int);
PS:マクロの定義: https://github.com/google/benchmark/blob/2d088a9f2d41acb77afc99d045f669e1a21b61ef/include/benchmark/benchmark_api.h#L684
我々はa
(a, b
)マクロの引数は<
と>
内部に入ることを見ることができ、 f< a,b >
:
// template<int arg>
// void BM_Foo(int iters);
//
// BENCHMARK_TEMPLATE(BM_Foo, 1);
//
// will register BM_Foo<1> as a benchmark.
#define BENCHMARK_TEMPLATE1(n, a) \
BENCHMARK_PRIVATE_DECLARE(n) = \
(::benchmark::internal::RegisterBenchmarkInternal(\
new ::benchmark::internal::FunctionBenchmark(#n "<" #a ">", n<a>)))
#define BENCHMARK_TEMPLATE2(n, a, b) \
BENCHMARK_PRIVATE_DECLARE(n) = \
(::benchmark::internal::RegisterBenchmarkInternal(\
new ::benchmark::internal::FunctionBenchmark( \
#n "<" #a "," #b ">", n<a, b>)))
#define BENCHMARK_TEMPLATE(n, ...) \
BENCHMARK_PRIVATE_DECLARE(n) = \
(::benchmark::internal::RegisterBenchmarkInternal(\
new ::benchmark::internal::FunctionBenchmark(\
#n "<" #__VA_ARGS__ ">", n<__VA_ARGS__>)))
したがって、BENCHMARK_TEMPLATE
は複数のバリアントを反復処理することはできず、1行からいくつかのバリアントを定義することはできません。