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

Function makeProtoData

valdi_protobuf/src/benchmark/Benchmark.cpp:9–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7using namespace Valdi;
8
9static BytesView makeProtoData() {
10 test::Message message;
11
12 message.set_int32(42);
13 message.set_int64(1337133713371337);
14 message.set_uint32(4294967294);
15 message.set_uint64(104294967296u);
16 message.set_sint32(-43);
17 message.set_sint64(-1337133713371337);
18 message.set_fixed32(42);
19 message.set_fixed64(10429496729600u);
20 message.set_sfixed32(-42);
21 message.set_sfixed64(-10429496729600);
22 message.set_float_(0.98765);
23 message.set_double_(0.987654321);
24 message.set_bool_(true);
25 message.set_string("Hello World and Welcome!");
26
27 std::string messageBytes;
28 while (messageBytes.length() < 2048) {
29 messageBytes += "abcdefghijklmnopqrstuvwxyz";
30 }
31 message.set_bytes(std::move(messageBytes));
32 message.set_enum_(test::Enum::VALUE_1);
33
34 auto* otherMessage = message.mutable_other_message();
35 otherMessage->set_value("Hello World!");
36
37 auto bytes = message.ByteSizeLong();
38 auto buffer = makeShared<ByteBuffer>();
39 buffer->resize(bytes);
40
41 SC_ASSERT(message.SerializeToArray(buffer->data(), buffer->size()));
42
43 return buffer->toBytesView();
44}
45
46static void DecodeProtobufCpp(benchmark::State& state) {
47 auto protoData = makeProtoData();

Callers 7

DecodeProtobufCppFunction · 0.85
EncodeProtobufCppFunction · 0.85
DecodeValdiProtobufFunction · 0.85
EncodeValdiProtobufFunction · 0.85

Calls 15

set_int32Method · 0.80
set_int64Method · 0.80
set_uint32Method · 0.80
set_uint64Method · 0.80
set_sint32Method · 0.80
set_sint64Method · 0.80
set_fixed32Method · 0.80
set_fixed64Method · 0.80
set_sfixed32Method · 0.80
set_sfixed64Method · 0.80
set_float_Method · 0.80
set_double_Method · 0.80

Tested by

no test coverage detected