Go to the documentation of this file.
26 #include <benchmark/benchmark.h>
29 #include "absl/container/flat_hash_set.h"
30 #include "benchmarks/descriptor.pb.h"
31 #include "benchmarks/descriptor.upb.h"
32 #include "benchmarks/descriptor.upbdefs.h"
33 #include "benchmarks/descriptor_sv.pb.h"
34 #include "google/ads/googleads/v7/services/google_ads_service.upbdefs.h"
35 #include "google/protobuf/descriptor.pb.h"
36 #include "google/protobuf/dynamic_message.h"
40 namespace protobuf = ::google::protobuf;
47 std::vector<upb_StringView>& serialized_files,
49 if (!
seen.insert(
file).second)
return;
53 serialized_files.push_back(
file->descriptor);
104 init->descriptor.data,
init->descriptor.size, NULL,
111 "Failed to parse compiled-in descriptor for file '%s'. This should "
128 "Error loading compiled-in descriptor for file '%s' (this should "
129 "never happen): %s\n",
134 template <LoadDescriptorMode Mode>
136 size_t bytes_per_iter = 0;
140 google_ads_googleads_v7_services_SearchGoogleAdsRequest_getmsgdef(
147 &google_ads_googleads_v7_services_google_ads_service_proto_upbdefinit,
151 state.SetBytesProcessed(
state.iterations() * bytes_per_iter);
156 template <LoadDescriptorMode Mode>
159 google_ads_googleads_v7_services_google_ads_service_proto_upbdefinit;
160 std::vector<upb_StringView> serialized_files;
163 &google_ads_googleads_v7_services_google_ads_service_proto_upbdefinit,
164 serialized_files, seen_files);
165 size_t bytes_per_iter = 0;
170 for (
auto file : serialized_files) {
173 protobuf::Arena::CreateMessage<protobuf::FileDescriptorProto>(&
arena);
175 pool.BuildFile(*proto) !=
nullptr;
177 printf(
"Failed to add file.\n");
180 bytes_per_iter +=
input.size();
186 "google.ads.googleads.v7.services.SearchGoogleAdsResponse");
188 printf(
"Failed to find descriptor.\n");
194 state.SetBytesProcessed(
state.iterations() * bytes_per_iter);
210 template <ArenaMode AMode, CopyStrings Copy>
219 upb_benchmark_FileDescriptorProto*
set =
220 upb_benchmark_FileDescriptorProto_parse_ex(
224 printf(
"Failed to parse.\n");
236 template <ArenaMode AMode,
class P>
267 opts.initial_block_size =
sizeof(
buf);
277 template <
class P, ArenaMode AMode, CopyStrings kCopy>
281 ? protobuf::MessageLite::ParseFlags::kMergePartial
282 : protobuf::MessageLite::ParseFlags::kMergePartialWithAliasing;
285 auto proto = proto_factory.GetProto();
287 bool ok = proto->template ParseFrom<kParseFlags>(
input);
289 printf(
"Failed to parse.\n");
304 proto.SerializePartialToArray(
buf,
sizeof(
buf));
313 upb_benchmark_FileDescriptorProto*
set =
317 printf(
"Failed to parse.\n");
324 upb_benchmark_FileDescriptorProto_serialize(
set, enc_arena, &
size);
326 printf(
"Failed to serialize.\n");
static _upb_DefPool_Init * deps[4]
const grpc_generator::File * file
upb_Arena * upb_Arena_Init(void *mem, size_t n, upb_alloc *alloc)
_Use_decl_annotations_ int __cdecl printf(const char *_Format,...)
static void BM_ArenaInitialBlockOneAlloc(benchmark::State &state)
BENCHMARK(BM_ArenaOneAlloc)
static void BM_SerializeDescriptor_Upb(benchmark::State &state)
const char * upb_Status_ErrorMessage(const upb_Status *status)
UPB_INLINE upb_Arena * upb_Arena_New(void)
void upb_Status_Clear(upb_Status *status)
grpc_core::ScopedArenaPtr arena
static void BM_LoadAdsDescriptor_Upb(benchmark::State &state)
UPB_INLINE void * upb_Arena_Malloc(upb_Arena *a, size_t size)
upb_StringView descriptor
::upb_benchmark::sv::FileDescriptorProto FileDescSV
void upb_Status_SetErrorFormat(upb_Status *status, const char *fmt,...)
@ kUpb_DecodeOption_AliasString
static void BM_LoadAdsDescriptor_Proto2(benchmark::State &state)
bool LoadDefInit_BuildLayout(upb_DefPool *s, const _upb_DefPool_Init *init, size_t *bytes)
static void BM_ArenaOneAlloc(benchmark::State &state)
void CollectFileDescriptors(const _upb_DefPool_Init *file, std::vector< upb_StringView > &serialized_files, absl::flat_hash_set< const _upb_DefPool_Init * > &seen)
void BM_Parse_Proto2(benchmark::State &state)
static PyObject * GetOptions(PyBaseDescriptor *self)
BENCHMARK_TEMPLATE(BM_LoadAdsDescriptor_Upb, NoLayout)
static void BM_Parse_Upb_FileDesc(benchmark::State &state)
protobuf::ArenaOptions GetOptions()
size_t _upb_DefPool_BytesLoaded(const upb_DefPool *s)
const upb_FileDef * upb_DefPool_AddFile(upb_DefPool *s, const google_protobuf_FileDescriptorProto *file_proto, upb_Status *status)
InternalDescriptorPool * pool
GRPC_CUSTOM_FILEDESCRIPTORPROTO FileDescriptorProto
::upb_benchmark::FileDescriptorProto FileDesc
UPB_INLINE google_protobuf_FileDescriptorProto * google_protobuf_FileDescriptorProto_parse_ex(const char *buf, size_t size, const upb_ExtensionRegistry *extreg, int options, upb_Arena *arena)
struct google_protobuf_FileDescriptorProto google_protobuf_FileDescriptorProto
void upb_Arena_Free(upb_Arena *a)
const Message * GetPrototype(const Descriptor *type) override
static void BM_SerializeDescriptor_Proto2(benchmark::State &state)
const upb_FileDef * upb_DefPool_FindFileByName(const upb_DefPool *s, const char *name)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:46