WIP.
diff --git a/benchmarks/BUILD b/benchmarks/BUILD index 87315a3..20d28dd 100644 --- a/benchmarks/BUILD +++ b/benchmarks/BUILD
@@ -51,3 +51,35 @@ "@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"], +)
diff --git a/benchmarks/protobuf_binary.cc b/benchmarks/protobuf_binary.cc new file mode 100644 index 0000000..b585aa6 --- /dev/null +++ b/benchmarks/protobuf_binary.cc
@@ -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); +}
diff --git a/benchmarks/small.proto b/benchmarks/small.proto new file mode 100644 index 0000000..cfc59c2 --- /dev/null +++ b/benchmarks/small.proto
@@ -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; +}
diff --git a/benchmarks/upb_binary.c b/benchmarks/upb_binary.c new file mode 100644 index 0000000..8e2d86b --- /dev/null +++ b/benchmarks/upb_binary.c
@@ -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; +}