|
| google_benchmark_manager ()=default |
|
| ~google_benchmark_manager ()=default |
|
void | initialize (int &argc, char **argv) |
| Initialize the Google Benchmark library.
|
|
template<typename Func , typename... Args> |
benchmark::internal::Benchmark * | add_gbench (const char *name, Func f, Args &&...args) |
| Register a benchmark function with Google Benchmark.
|
|
void | run () |
| Run the registered benchmarks.
|
|
Manager class for Google Benchmark integration.
This class handles the initialization, registration, and execution of benchmarks using the Google Benchmark library. It provides methods to initialize the library with command-line arguments, register benchmark functions, and run the benchmarks.
template<typename Func , typename... Args>
benchmark::internal::Benchmark * comppare::plugin::google_benchmark::google_benchmark_manager::add_gbench |
( |
const char * |
name, |
|
|
Func |
f, |
|
|
Args &&... |
args |
|
) |
| |
|
inline |
Register a benchmark function with Google Benchmark.
- Template Parameters
-
Func | The type of the benchmark function. |
Args | The types of the arguments to the benchmark function. |
- Parameters
-
name | The name of the benchmark. |
f | The function/implementation to register. |
args | The arguments to pass to the benchmark function. |
- Returns
- A pointer to the registered benchmark.
This helper simplifies registering a benchmark by automatically wrapping the provided function and its arguments into a Google Benchmark-compatible lambda. The lambda sets the current benchmark state and invokes the function with the captured arguments.
Usage example:
void saxpy(int n, float a, const float* x, float* y);
add_gbench(
"SAXPY", saxpy, 1<<20, 2.0f, x_data, y_data);
benchmark::internal::Benchmark * add_gbench(const char *name, Func f, Args &&...args)
Register a benchmark function with Google Benchmark.
Definition google_benchmark.hpp:158
This is equivalent to writing a manual Google Benchmark function:
static void BM_SAXPY(benchmark::State& st) {
for (auto _ : st) {
saxpy(1<<20, 2.0f, x_data, y_data);
}
}
BENCHMARK(BM_SAXPY);