
Create tests/google_benchmark/benchmark_*.cpp and register it in CMakeLists.txt
Source:R/use-google-benchmark-template.R
use_google_benchmark_template.RdThis helper function generates a Google Benchmark C++ template file for a
given workload and appends lines to tests/google_benchmark/CMakeLists.txt
to register the benchmark as a separate executable.
Usage
use_google_benchmark_template(
name = "FileName_ClassName_FunctionName",
type = c("simple", "fixture")
)Arguments
- name
A string representing the name for the C++ benchmark file and CMake executable target. It must follow the format
FileName_ClassName_FunctionName, whereFileNameis the C++ source file nameClassNameis the C++ class name (or a placeholder such asClassName)FunctionNameis the C++ function name and underscores separate each component. For example:Population_CatchAtAge_CatchNumbersAtAge.
The generated file will be
tests/google_benchmark/benchmark_<name>.cppand the CMake target will bebenchmark_<name>.- type
Benchmark template type. Use
"simple"for direct benchmarking without gtest fixtures, or"fixture"to generate a fixture-based template that includes gtest.
Value
If successful, this function invisibly returns TRUE to allow for the
chaining of commands. If the function is unsuccessful, an error message is
returned.
Messages from the usethis package and cli indicate where the new file was
created and that the benchmark was registered in
tests/google_benchmark/CMakeLists.txt.
Examples
if (FALSE) { # \dontrun{
# Create a new benchmark file and register it in CMake:
FIMS:::use_google_benchmark_template(
name = "Population_CatchAtAge_CatchNumbersAtAge"
)
# Create a fixture-based benchmark template:
FIMS:::use_google_benchmark_template(
name = "Population_CatchAtAge_CatchNumbersAtAge",
type = "fixture"
)
} # }