hpb cleanup: abrogate protos::{ClearMessage,CloneMessage,CreateMessage,DeepCopy} with hpb::{...}

PiperOrigin-RevId: 665350963
pull/17859/head
Hong Shin 3 months ago committed by Copybara-Service
parent 6d84da5e2d
commit 7a4319428b
  1. 3
      protos/protos.h
  2. 2
      rust/test/benchmarks/BUILD
  3. 9
      rust/test/benchmarks/rust_protobuf_benchmarks.cc

@ -25,10 +25,7 @@ using hpb::internal::PrivateAccess;
using hpb::internal::Serialize; using hpb::internal::Serialize;
using hpb::internal::SetExtension; using hpb::internal::SetExtension;
} // namespace internal } // namespace internal
using hpb::ClearMessage;
using hpb::CloneMessage;
using hpb::CreateMessage; using hpb::CreateMessage;
using hpb::DeepCopy;
using hpb::Parse; using hpb::Parse;
using hpb::Serialize; using hpb::Serialize;

@ -48,6 +48,7 @@ cc_test(
":bench_data_upb_cc_proto", ":bench_data_upb_cc_proto",
":benchmarks", ":benchmarks",
":proto_benchmarks_cpp", # build_cleaner: keep ":proto_benchmarks_cpp", # build_cleaner: keep
"//hpb",
"//hpb:repeated_field", "//hpb:repeated_field",
"//protos", "//protos",
"//src/google/protobuf:protobuf_lite", "//src/google/protobuf:protobuf_lite",
@ -69,6 +70,7 @@ cc_test(
":bench_data_upb_cc_proto", ":bench_data_upb_cc_proto",
":benchmarks", ":benchmarks",
":proto_benchmarks_upb", # build_cleaner: keep ":proto_benchmarks_upb", # build_cleaner: keep
"//hpb",
"//hpb:repeated_field", "//hpb:repeated_field",
"//protos", "//protos",
"//src/google/protobuf:protobuf_lite", "//src/google/protobuf:protobuf_lite",

@ -5,6 +5,7 @@
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include "absl/log/absl_check.h" #include "absl/log/absl_check.h"
#include "google/protobuf/hpb/hpb.h"
#include "google/protobuf/repeated_ptr_field.h" #include "google/protobuf/repeated_ptr_field.h"
#include "google/protobuf/rust/test/benchmarks/bench_data.pb.h" #include "google/protobuf/rust/test/benchmarks/bench_data.pb.h"
#include "google/protobuf/rust/test/benchmarks/bench_data.upb.proto.h" #include "google/protobuf/rust/test/benchmarks/bench_data.upb.proto.h"
@ -142,7 +143,7 @@ BENCHMARK(BM_add_100_ints_cpp);
void BM_add_100_ints_upb(benchmark::State& state) { void BM_add_100_ints_upb(benchmark::State& state) {
for (auto s : state) { for (auto s : state) {
::protos::Arena arena; ::protos::Arena arena;
auto data = ::protos::CreateMessage<benchmarks::protos::BenchData>(arena); auto data = ::hpb::CreateMessage<benchmarks::protos::BenchData>(arena);
for (int i = 0; i < 100; ++i) { for (int i = 0; i < 100; ++i) {
data.add_nums(i); data.add_nums(i);
} }
@ -184,12 +185,12 @@ BENCHMARK(BM_copy_from_100_ints_cpp);
void BM_copy_from_100_ints_upb(benchmark::State& state) { void BM_copy_from_100_ints_upb(benchmark::State& state) {
::protos::Arena arena; ::protos::Arena arena;
auto source = ::protos::CreateMessage<benchmarks::protos::BenchData>(arena); auto source = ::hpb::CreateMessage<benchmarks::protos::BenchData>(arena);
for (int i = 0; i < 100; ++i) { for (int i = 0; i < 100; ++i) {
source.add_nums(i); source.add_nums(i);
} }
for (auto s : state) { for (auto s : state) {
auto data = ::protos::CreateMessage<benchmarks::protos::BenchData>(arena); auto data = ::hpb::CreateMessage<benchmarks::protos::BenchData>(arena);
data.resize_nums(source.nums_size()); data.resize_nums(source.nums_size());
std::copy(source.nums().begin(), source.nums().end(), std::copy(source.nums().begin(), source.nums().end(),
data.mutable_nums()->begin()); data.mutable_nums()->begin());
@ -228,7 +229,7 @@ BENCHMARK(BM_sum_1000_ints_cpp);
void BM_sum_1000_ints_upb(benchmark::State& state) { void BM_sum_1000_ints_upb(benchmark::State& state) {
::protos::Arena arena; ::protos::Arena arena;
auto data = ::protos::CreateMessage<benchmarks::protos::BenchData>(arena); auto data = ::hpb::CreateMessage<benchmarks::protos::BenchData>(arena);
for (int i = 0; i < 1000; ++i) { for (int i = 0; i < 1000; ++i) {
data.add_nums(i); data.add_nums(i);
} }

Loading…
Cancel
Save