split protobuf rust benchmark into separate binaries for upb/cpp

PiperOrigin-RevId: 642617950
pull/17118/head
Derek Benson 10 months ago committed by Copybara-Service
parent 1b451603f6
commit db06125563
  1. 22
      rust/test/benchmarks/BUILD
  2. 10
      rust/test/benchmarks/rust_protobuf_benchmarks.cc

@ -40,7 +40,7 @@ upb_cc_proto_library(
)
cc_test(
name = "rust_protobuf_benchmarks",
name = "rust_protobuf_benchmarks_cpp",
testonly = True,
srcs = ["rust_protobuf_benchmarks.cc"],
deps = [
@ -48,6 +48,26 @@ cc_test(
":bench_data_upb_cc_proto",
":benchmarks",
":proto_benchmarks_cpp", # build_cleaner: keep
"//protos",
"//protos:repeated_field",
"//src/google/protobuf:protobuf_lite",
"//testing/base/public:gunit",
"//third_party/benchmark",
"@com_google_absl//absl/log:absl_check",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)
cc_test(
name = "rust_protobuf_benchmarks_upb",
testonly = True,
srcs = ["rust_protobuf_benchmarks.cc"],
defines = ["BENCHMARK_UPB"],
deps = [
":bench_data_cc_proto",
":bench_data_upb_cc_proto",
":benchmarks",
":proto_benchmarks_upb", # build_cleaner: keep
"//protos",
"//protos:repeated_field",

@ -12,6 +12,12 @@
using benchmarks::BenchData;
#ifdef BENCHMARK_UPB
#define PROTO_BENCHMARK(NAME) EXTERN_BENCHMARK(NAME##_upb);
#else
#define PROTO_BENCHMARK(NAME) EXTERN_BENCHMARK(NAME##_cpp);
#endif
#define EXTERN_BENCHMARK(NAME) \
extern "C" { \
void NAME##_bench(); \
@ -23,10 +29,6 @@ using benchmarks::BenchData;
} \
BENCHMARK(BM_##NAME);
#define PROTO_BENCHMARK(NAME) \
EXTERN_BENCHMARK(NAME##_cpp); \
EXTERN_BENCHMARK(NAME##_upb);
void BM_set_string_cpp(benchmark::State& state) {
for (auto s : state) {
auto data = std::make_unique<BenchData>();

Loading…
Cancel
Save