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

Function EncodeProtobufCpp

valdi_protobuf/src/benchmark/Benchmark.cpp:72–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70BENCHMARK(DecodeProtobufReflectionCpp);
71
72static void EncodeProtobufCpp(benchmark::State& state) {
73 auto protoData = makeProtoData();
74 auto message = makeShared<test::Message>();
75 if (!message->ParseFromArray(protoData.data(), protoData.size())) {
76 SC_ABORT("Message failed to parse");
77 }
78
79 for (auto _ : state) {
80 auto buffer = makeShared<ByteBuffer>();
81 buffer->resize(message->ByteSizeLong());
82
83 if (!message->SerializeToArray(buffer->data(), buffer->size())) {
84 SC_ABORT("Message failed to serialize");
85 }
86 }
87}
88BENCHMARK(EncodeProtobufCpp);
89
90static void EncodeProtobufReflectionCpp(benchmark::State& state) {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected