]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/bazel/otel_cc_benchmark.bzl
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / bazel / otel_cc_benchmark.bzl
1 def otel_cc_benchmark(name, srcs, deps, tags = [""]):
2 """
3 Creates targets for the benchmark and related targets.
4
5 Example:
6
7 otel_cc_benchmark(
8 name = "foo_benchmark",
9 srcs = ["foo_benchmark.cc"],
10 deps = ["//bar"],
11 )
12
13 Creates:
14
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)
18 """
19
20 # This is the benchmark as a binary, it can be run manually, and is used
21 # to generate the _result below.
22 native.cc_binary(
23 name = name,
24 srcs = srcs,
25 deps = deps + ["@com_github_google_benchmark//:benchmark"],
26 tags = tags + ["manual"],
27 defines = ["BAZEL_BUILD"],
28 )
29
30 # The result of running the benchmark, captured into a text file.
31 native.genrule(
32 name = name + "_result",
33 outs = [name + "_result.json"],
34 tools = [":" + name],
35 tags = tags + ["benchmark_result", "manual"],
36 testonly = True,
37 cmd = "$(location :" + name + (") --benchmark_format=json --benchmark_color=false --benchmark_min_time=.1 &> $@"),
38 )
39
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.
42 native.cc_test(
43 name = name + "_smoketest",
44 srcs = srcs,
45 deps = deps + ["@com_github_google_benchmark//:benchmark"],
46 args = ["--benchmark_min_time=0"],
47 tags = tags + ["benchmark"],
48 defines = ["BAZEL_BUILD"],
49 )