You can now use CodSpeed with Bazel build systems thanks to our enhanced C++ integration!
This addition complements our existing CMake support, making it easier to benchmark large-scale C++ projects with complex build configurations. Bazel support is particularly valuable for enterprise teams working with monorepos and sophisticated dependency management.
Add CodSpeed to your Bazel workspace by adding this to your WORKSPACE
file:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "codspeed_cpp",
urls = ["https://github.com/CodSpeedHQ/codspeed-cpp/archive/refs/heads/main.zip"],
strip_prefix = "codspeed-cpp-main",
)
Then define your benchmark target in your package's BUILD.bazel
file:
cc_binary(
name = "my_benchmark",
srcs = glob(["*.cpp", "*.hpp"]),
deps = [
"@codspeed_cpp//google_benchmark:benchmark",
],
)
Build and run your benchmarks with the CodSpeed instrumentation flag:
# Build your benchmark
bazel build //path/to/bench:my_benchmark --@codspeed_cpp//core:codspeed_mode=instrumentation
# Run it locally
bazel run //path/to/bench:my_benchmark --@codspeed_cpp//core:codspeed_mode=instrumentation
For more information, check out the Bazel section of C++ documentation.