MCPcopy Create free account
hub / github.com/Snapchat/Valdi / EncodeProtobufReflectionCpp

Function EncodeProtobufReflectionCpp

valdi_protobuf/src/benchmark/Benchmark.cpp:90–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88BENCHMARK(EncodeProtobufCpp);
89
90static void EncodeProtobufReflectionCpp(benchmark::State& state) {
91 auto protoData = makeProtoData();
92 google::protobuf::DynamicMessageFactory factory;
93 auto* prototype = factory.GetPrototype(test::Message::GetDescriptor());
94 auto message = prototype->New();
95 if (!message->ParseFromArray(protoData.data(), protoData.size())) {
96 SC_ABORT("Message failed to parse");
97 }
98
99 for (auto _ : state) {
100 auto buffer = makeShared<ByteBuffer>();
101 buffer->resize(message->ByteSizeLong());
102
103 if (!message->SerializeToArray(buffer->data(), buffer->size())) {
104 SC_ABORT("Message failed to serialize");
105 }
106 }
107}
108BENCHMARK(EncodeProtobufReflectionCpp);
109
110static void DecodeValdiProtobuf(benchmark::State& state) {

Callers

nothing calls this directly

Calls 7

makeProtoDataFunction · 0.85
GetDescriptorFunction · 0.85
NewMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
ByteSizeLongMethod · 0.45

Tested by

no test coverage detected