1 def otel_cc_benchmark(name, srcs, deps, tags = [""]):
3 Creates targets for the benchmark and related targets.
8 name = "foo_benchmark",
9 srcs = ["foo_benchmark.cc"],
15 :foo_benchmark (the benchmark binary)
16 :foo_benchmark_result (results from running the benchmark)
17 :foo_benchmark_smoketest (a fast test that runs a single iteration)
20 # This is the benchmark as a binary, it can be run manually, and is used
21 # to generate the _result below.
25 deps = deps + ["@com_github_google_benchmark//:benchmark"],
26 tags = tags + ["manual"],
27 defines = ["BAZEL_BUILD"],
30 # The result of running the benchmark, captured into a text file.
32 name = name + "_result",
33 outs = [name + "_result.json"],
35 tags = tags + ["benchmark_result", "manual"],
37 cmd = "$(location :" + name + (") --benchmark_format=json --benchmark_color=false --benchmark_min_time=.1 &> $@"),
40 # This is run as part of "bazel test ..." to smoke-test benchmarks. It's
41 # meant to complete quickly rather than get accurate results.
43 name = name + "_smoketest",
45 deps = deps + ["@com_github_google_benchmark//:benchmark"],
46 args = ["--benchmark_min_time=0"],
47 tags = tags + ["benchmark"],
48 defines = ["BAZEL_BUILD"],