|
|
|
@ -4,6 +4,7 @@ |
|
|
|
|
#include "google/protobuf/descriptor.upb.h" |
|
|
|
|
#include "google/protobuf/descriptor.upbdefs.h" |
|
|
|
|
#include "google/protobuf/descriptor.pb.h" |
|
|
|
|
#include "upb/def.hpp" |
|
|
|
|
|
|
|
|
|
upb_strview descriptor = google_protobuf_descriptor_proto_upbdefinit.descriptor; |
|
|
|
|
namespace protobuf = ::google::protobuf; |
|
|
|
@ -29,6 +30,22 @@ static void BM_ArenaInitialBlockOneAlloc(benchmark::State& state) { |
|
|
|
|
} |
|
|
|
|
BENCHMARK(BM_ArenaInitialBlockOneAlloc); |
|
|
|
|
|
|
|
|
|
static void BM_LoadDescriptor(benchmark::State& state) { |
|
|
|
|
for (auto _ : state) { |
|
|
|
|
upb::SymbolTable symtab; |
|
|
|
|
upb::Arena arena; |
|
|
|
|
google_protobuf_FileDescriptorProto* file_proto = |
|
|
|
|
google_protobuf_FileDescriptorProto_parse(descriptor.data, |
|
|
|
|
descriptor.size, arena.ptr()); |
|
|
|
|
upb::FileDefPtr file_def = symtab.AddFile(file_proto, NULL); |
|
|
|
|
if (!file_def) { |
|
|
|
|
printf("Failed to add file.\n"); |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
BENCHMARK(BM_LoadDescriptor); |
|
|
|
|
|
|
|
|
|
static void BM_ParseDescriptor_Upb_LargeInitialBlock(benchmark::State& state) { |
|
|
|
|
size_t bytes = 0; |
|
|
|
|
for (auto _ : state) { |
|
|
|
|