summaryrefslogtreecommitdiffstats
path: root/src/jaegertracing/opentelemetry-cpp/bazel/otel_cc_benchmark.bzl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/jaegertracing/opentelemetry-cpp/bazel/otel_cc_benchmark.bzl
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/jaegertracing/opentelemetry-cpp/bazel/otel_cc_benchmark.bzl')
-rw-r--r--src/jaegertracing/opentelemetry-cpp/bazel/otel_cc_benchmark.bzl49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/jaegertracing/opentelemetry-cpp/bazel/otel_cc_benchmark.bzl b/src/jaegertracing/opentelemetry-cpp/bazel/otel_cc_benchmark.bzl
new file mode 100644
index 000000000..c40681917
--- /dev/null
+++ b/src/jaegertracing/opentelemetry-cpp/bazel/otel_cc_benchmark.bzl
@@ -0,0 +1,49 @@
+def otel_cc_benchmark(name, srcs, deps, tags = [""]):
+ """
+ Creates targets for the benchmark and related targets.
+
+ Example:
+
+ otel_cc_benchmark(
+ name = "foo_benchmark",
+ srcs = ["foo_benchmark.cc"],
+ deps = ["//bar"],
+ )
+
+ Creates:
+
+ :foo_benchmark (the benchmark binary)
+ :foo_benchmark_result (results from running the benchmark)
+ :foo_benchmark_smoketest (a fast test that runs a single iteration)
+ """
+
+ # This is the benchmark as a binary, it can be run manually, and is used
+ # to generate the _result below.
+ native.cc_binary(
+ name = name,
+ srcs = srcs,
+ deps = deps + ["@com_github_google_benchmark//:benchmark"],
+ tags = tags + ["manual"],
+ defines = ["BAZEL_BUILD"],
+ )
+
+ # The result of running the benchmark, captured into a text file.
+ native.genrule(
+ name = name + "_result",
+ outs = [name + "_result.json"],
+ tools = [":" + name],
+ tags = tags + ["benchmark_result", "manual"],
+ testonly = True,
+ cmd = "$(location :" + name + (") --benchmark_format=json --benchmark_color=false --benchmark_min_time=.1 &> $@"),
+ )
+
+ # This is run as part of "bazel test ..." to smoke-test benchmarks. It's
+ # meant to complete quickly rather than get accurate results.
+ native.cc_test(
+ name = name + "_smoketest",
+ srcs = srcs,
+ deps = deps + ["@com_github_google_benchmark//:benchmark"],
+ args = ["--benchmark_min_time=0"],
+ tags = tags + ["benchmark"],
+ defines = ["BAZEL_BUILD"],
+ )