pull/13171/head
Joshua Haberman 4 years ago
parent a7e2e8338d
commit 8a3470c543
  1. 32
      benchmarks/BUILD
  2. 10
      benchmarks/protobuf_binary.cc
  3. 35
      benchmarks/small.proto
  4. 12
      benchmarks/upb_binary.c

@ -51,3 +51,35 @@ cc_binary(
"@com_google_protobuf//:protobuf",
],
)
# Size benchmarks.
upb_proto_library(
name = "empty_upb_proto",
deps = ["@com_google_protobuf//:empty_proto"],
)
cc_proto_library(
name = "empty_cc_proto",
deps = ["@com_google_protobuf//:empty_proto"],
)
cc_binary(
name = "upb_binary",
testonly = 1,
srcs = ["upb_binary.c"],
deps = [
":empty_upb_proto",
],
#features = ["fully_static_link"],
)
cc_binary(
name = "protobuf_binary",
testonly = 1,
srcs = ["protobuf_binary.cc"],
deps = [
":empty_cc_proto",
],
#features = ["fully_static_link"],
)

@ -0,0 +1,10 @@
#include "google/protobuf/empty.pb.h"
char buf[1];
int main() {
google::protobuf::Empty proto;
proto.ParseFromArray(buf, 1);
proto.SerializeToArray(buf, 1);
}

@ -0,0 +1,35 @@
// A small proto, for measuring the overhead of a minimal use of
// protocol buffers.
syntax = "proto3";
option optimize_for = LITE_RUNTIME;
option cc_enable_arenas = true;
package upb_benchmark;
message Person {
string name = 1;
int32 id = 2; // Unique ID number for this person.
string email = 3;
enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;
}
message PhoneNumber {
string number = 1;
PhoneType type = 2;
}
repeated PhoneNumber phones = 4;
int64 last_updated = 5;
}
// Our address book file is just one of these.
message AddressBook {
repeated Person people = 1;
}

@ -0,0 +1,12 @@
#include "google/protobuf/empty.upb.h"
char buf[1];
int main() {
upb_arena *arena = upb_arena_new();
size_t size;
google_protobuf_Empty *proto = google_protobuf_Empty_parse(buf, 1, arena);
google_protobuf_Empty_serialize(proto, arena, &size);
return 0;
}
Loading…
Cancel
Save