mirror of
https://github.com/capnproto/pycapnp.git
synced 2025-03-04 08:24:43 +01:00
Merge branch 'py3benchmarks'
This commit is contained in:
commit
f01a691c34
15 changed files with 184 additions and 81 deletions
|
@ -1,8 +1,11 @@
|
|||
syntax = "proto2";
|
||||
|
||||
package tutorial;
|
||||
|
||||
message Person {
|
||||
required string name = 1;
|
||||
required int32 id = 2;
|
||||
required string email = 3;
|
||||
|
||||
enum PhoneType {
|
||||
MOBILE = 0;
|
||||
|
@ -15,7 +18,7 @@ message Person {
|
|||
optional PhoneType type = 2 [default = HOME];
|
||||
}
|
||||
|
||||
repeated PhoneNumber phone = 3;
|
||||
repeated PhoneNumber phone = 4;
|
||||
}
|
||||
|
||||
message AddressBook {
|
||||
|
|
|
@ -1,19 +1,26 @@
|
|||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: addressbook.proto
|
||||
|
||||
import sys
|
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import message as _message
|
||||
from google.protobuf import reflection as _reflection
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf import descriptor_pb2
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor(
|
||||
name='addressbook.proto',
|
||||
package='tutorial',
|
||||
serialized_pb='\n\x11\x61\x64\x64ressbook.proto\x12\x08tutorial\"\xda\x01\n\x06Person\x12\x0c\n\x04name\x18\x01 \x02(\t\x12\n\n\x02id\x18\x02 \x02(\x05\x12\r\n\x05\x65mail\x18\x03 \x01(\t\x12+\n\x05phone\x18\x04 \x03(\x0b\x32\x1c.tutorial.Person.PhoneNumber\x1aM\n\x0bPhoneNumber\x12\x0e\n\x06number\x18\x01 \x02(\t\x12.\n\x04type\x18\x02 \x01(\x0e\x32\x1a.tutorial.Person.PhoneType:\x04HOME\"+\n\tPhoneType\x12\n\n\x06MOBILE\x10\x00\x12\x08\n\x04HOME\x10\x01\x12\x08\n\x04WORK\x10\x02\"/\n\x0b\x41\x64\x64ressBook\x12 \n\x06person\x18\x01 \x03(\x0b\x32\x10.tutorial.Person')
|
||||
syntax='proto2',
|
||||
serialized_pb=_b('\n\x11\x61\x64\x64ressbook.proto\x12\x08tutorial\"\xda\x01\n\x06Person\x12\x0c\n\x04name\x18\x01 \x02(\t\x12\n\n\x02id\x18\x02 \x02(\x05\x12\r\n\x05\x65mail\x18\x03 \x02(\t\x12+\n\x05phone\x18\x04 \x03(\x0b\x32\x1c.tutorial.Person.PhoneNumber\x1aM\n\x0bPhoneNumber\x12\x0e\n\x06number\x18\x01 \x02(\t\x12.\n\x04type\x18\x02 \x01(\x0e\x32\x1a.tutorial.Person.PhoneType:\x04HOME\"+\n\tPhoneType\x12\n\n\x06MOBILE\x10\x00\x12\x08\n\x04HOME\x10\x01\x12\x08\n\x04WORK\x10\x02\"/\n\x0b\x41\x64\x64ressBook\x12 \n\x06person\x18\x01 \x03(\x0b\x32\x10.tutorial.Person')
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
@ -41,6 +48,7 @@ _PERSON_PHONETYPE = _descriptor.EnumDescriptor(
|
|||
serialized_start=207,
|
||||
serialized_end=250,
|
||||
)
|
||||
_sym_db.RegisterEnumDescriptor(_PERSON_PHONETYPE)
|
||||
|
||||
|
||||
_PERSON_PHONENUMBER = _descriptor.Descriptor(
|
||||
|
@ -53,7 +61,7 @@ _PERSON_PHONENUMBER = _descriptor.Descriptor(
|
|||
_descriptor.FieldDescriptor(
|
||||
name='number', full_name='tutorial.Person.PhoneNumber.number', index=0,
|
||||
number=1, type=9, cpp_type=9, label=2,
|
||||
has_default_value=False, default_value=unicode("", "utf-8"),
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
|
@ -72,7 +80,10 @@ _PERSON_PHONENUMBER = _descriptor.Descriptor(
|
|||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto2',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=128,
|
||||
serialized_end=205,
|
||||
)
|
||||
|
@ -87,7 +98,7 @@ _PERSON = _descriptor.Descriptor(
|
|||
_descriptor.FieldDescriptor(
|
||||
name='name', full_name='tutorial.Person.name', index=0,
|
||||
number=1, type=9, cpp_type=9, label=2,
|
||||
has_default_value=False, default_value=unicode("", "utf-8"),
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
|
@ -100,8 +111,8 @@ _PERSON = _descriptor.Descriptor(
|
|||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='email', full_name='tutorial.Person.email', index=2,
|
||||
number=3, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=unicode("", "utf-8"),
|
||||
number=3, type=9, cpp_type=9, label=2,
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
|
@ -121,7 +132,10 @@ _PERSON = _descriptor.Descriptor(
|
|||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto2',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=32,
|
||||
serialized_end=250,
|
||||
)
|
||||
|
@ -149,36 +163,44 @@ _ADDRESSBOOK = _descriptor.Descriptor(
|
|||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto2',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=252,
|
||||
serialized_end=299,
|
||||
)
|
||||
|
||||
_PERSON_PHONENUMBER.fields_by_name['type'].enum_type = _PERSON_PHONETYPE
|
||||
_PERSON_PHONENUMBER.containing_type = _PERSON;
|
||||
_PERSON_PHONENUMBER.containing_type = _PERSON
|
||||
_PERSON.fields_by_name['phone'].message_type = _PERSON_PHONENUMBER
|
||||
_PERSON_PHONETYPE.containing_type = _PERSON;
|
||||
_PERSON_PHONETYPE.containing_type = _PERSON
|
||||
_ADDRESSBOOK.fields_by_name['person'].message_type = _PERSON
|
||||
DESCRIPTOR.message_types_by_name['Person'] = _PERSON
|
||||
DESCRIPTOR.message_types_by_name['AddressBook'] = _ADDRESSBOOK
|
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
||||
|
||||
class Person(_message.Message):
|
||||
__metaclass__ = _reflection.GeneratedProtocolMessageType
|
||||
|
||||
class PhoneNumber(_message.Message):
|
||||
__metaclass__ = _reflection.GeneratedProtocolMessageType
|
||||
DESCRIPTOR = _PERSON_PHONENUMBER
|
||||
Person = _reflection.GeneratedProtocolMessageType('Person', (_message.Message,), dict(
|
||||
|
||||
PhoneNumber = _reflection.GeneratedProtocolMessageType('PhoneNumber', (_message.Message,), dict(
|
||||
DESCRIPTOR = _PERSON_PHONENUMBER,
|
||||
__module__ = 'addressbook_pb2'
|
||||
# @@protoc_insertion_point(class_scope:tutorial.Person.PhoneNumber)
|
||||
DESCRIPTOR = _PERSON
|
||||
|
||||
))
|
||||
,
|
||||
DESCRIPTOR = _PERSON,
|
||||
__module__ = 'addressbook_pb2'
|
||||
# @@protoc_insertion_point(class_scope:tutorial.Person)
|
||||
))
|
||||
_sym_db.RegisterMessage(Person)
|
||||
_sym_db.RegisterMessage(Person.PhoneNumber)
|
||||
|
||||
class AddressBook(_message.Message):
|
||||
__metaclass__ = _reflection.GeneratedProtocolMessageType
|
||||
DESCRIPTOR = _ADDRESSBOOK
|
||||
|
||||
AddressBook = _reflection.GeneratedProtocolMessageType('AddressBook', (_message.Message,), dict(
|
||||
DESCRIPTOR = _ADDRESSBOOK,
|
||||
__module__ = 'addressbook_pb2'
|
||||
# @@protoc_insertion_point(class_scope:tutorial.AddressBook)
|
||||
))
|
||||
_sym_db.RegisterMessage(AddressBook)
|
||||
|
||||
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
|
|
|
@ -39,7 +39,7 @@ def run_one(prefix, name, mode, iters, faster, compression):
|
|||
data = {}
|
||||
|
||||
if p.returncode != 0:
|
||||
sys.stderr.write(' '.join(command) + ' failed to run with errors: \n' + p.stderr.read() + '\n')
|
||||
sys.stderr.write(' '.join(command) + ' failed to run with errors: \n' + p.stderr.read().decode(sys.stdout.encoding) + '\n')
|
||||
sys.stderr.flush()
|
||||
|
||||
data['type'] = res_type
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package capnp.benchmark.protobuf;
|
||||
|
||||
message ParkingLot {
|
||||
|
|
|
@ -1,20 +1,27 @@
|
|||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: carsales.proto
|
||||
|
||||
import sys
|
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
|
||||
from google.protobuf.internal import enum_type_wrapper
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import message as _message
|
||||
from google.protobuf import reflection as _reflection
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf import descriptor_pb2
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor(
|
||||
name='carsales.proto',
|
||||
package='capnp.benchmark.protobuf',
|
||||
serialized_pb='\n\x0e\x63\x61rsales.proto\x12\x18\x63\x61pnp.benchmark.protobuf\"8\n\nParkingLot\x12*\n\x03\x63\x61r\x18\x01 \x03(\x0b\x32\x1d.capnp.benchmark.protobuf.Car\"\x1c\n\nTotalValue\x12\x0e\n\x06\x61mount\x18\x01 \x02(\x04\"\xbc\x03\n\x03\x43\x61r\x12\x0c\n\x04make\x18\x01 \x01(\t\x12\r\n\x05model\x18\x02 \x01(\t\x12.\n\x05\x63olor\x18\x03 \x01(\x0e\x32\x1f.capnp.benchmark.protobuf.Color\x12\r\n\x05seats\x18\x04 \x01(\r\x12\r\n\x05\x64oors\x18\x05 \x01(\r\x12.\n\x05wheel\x18\x06 \x03(\x0b\x32\x1f.capnp.benchmark.protobuf.Wheel\x12\x0e\n\x06length\x18\x07 \x01(\r\x12\r\n\x05width\x18\x08 \x01(\r\x12\x0e\n\x06height\x18\t \x01(\r\x12\x0e\n\x06weight\x18\n \x01(\r\x12\x30\n\x06\x65ngine\x18\x0b \x01(\x0b\x32 .capnp.benchmark.protobuf.Engine\x12\x15\n\rfuel_capacity\x18\x0c \x01(\x02\x12\x12\n\nfuel_level\x18\r \x01(\x02\x12\x19\n\x11has_power_windows\x18\x0e \x01(\x08\x12\x1a\n\x12has_power_steering\x18\x0f \x01(\x08\x12\x1a\n\x12has_cruise_control\x18\x10 \x01(\x08\x12\x13\n\x0b\x63up_holders\x18\x11 \x01(\r\x12\x16\n\x0ehas_nav_system\x18\x12 \x01(\x08\"C\n\x05Wheel\x12\x10\n\x08\x64iameter\x18\x01 \x01(\r\x12\x14\n\x0c\x61ir_pressure\x18\x02 \x01(\x02\x12\x12\n\nsnow_tires\x18\x03 \x01(\x08\"d\n\x06\x45ngine\x12\x12\n\nhorsepower\x18\x01 \x01(\r\x12\x11\n\tcylinders\x18\x02 \x01(\r\x12\n\n\x02\x63\x63\x18\x03 \x01(\r\x12\x10\n\x08uses_gas\x18\x04 \x01(\x08\x12\x15\n\ruses_electric\x18\x05 \x01(\x08*j\n\x05\x43olor\x12\t\n\x05\x42LACK\x10\x00\x12\t\n\x05WHITE\x10\x01\x12\x07\n\x03RED\x10\x02\x12\t\n\x05GREEN\x10\x03\x12\x08\n\x04\x42LUE\x10\x04\x12\x08\n\x04\x43YAN\x10\x05\x12\x0b\n\x07MAGENTA\x10\x06\x12\n\n\x06YELLOW\x10\x07\x12\n\n\x06SILVER\x10\x08')
|
||||
syntax='proto2',
|
||||
serialized_pb=_b('\n\x0e\x63\x61rsales.proto\x12\x18\x63\x61pnp.benchmark.protobuf\"8\n\nParkingLot\x12*\n\x03\x63\x61r\x18\x01 \x03(\x0b\x32\x1d.capnp.benchmark.protobuf.Car\"\x1c\n\nTotalValue\x12\x0e\n\x06\x61mount\x18\x01 \x02(\x04\"\xbc\x03\n\x03\x43\x61r\x12\x0c\n\x04make\x18\x01 \x01(\t\x12\r\n\x05model\x18\x02 \x01(\t\x12.\n\x05\x63olor\x18\x03 \x01(\x0e\x32\x1f.capnp.benchmark.protobuf.Color\x12\r\n\x05seats\x18\x04 \x01(\r\x12\r\n\x05\x64oors\x18\x05 \x01(\r\x12.\n\x05wheel\x18\x06 \x03(\x0b\x32\x1f.capnp.benchmark.protobuf.Wheel\x12\x0e\n\x06length\x18\x07 \x01(\r\x12\r\n\x05width\x18\x08 \x01(\r\x12\x0e\n\x06height\x18\t \x01(\r\x12\x0e\n\x06weight\x18\n \x01(\r\x12\x30\n\x06\x65ngine\x18\x0b \x01(\x0b\x32 .capnp.benchmark.protobuf.Engine\x12\x15\n\rfuel_capacity\x18\x0c \x01(\x02\x12\x12\n\nfuel_level\x18\r \x01(\x02\x12\x19\n\x11has_power_windows\x18\x0e \x01(\x08\x12\x1a\n\x12has_power_steering\x18\x0f \x01(\x08\x12\x1a\n\x12has_cruise_control\x18\x10 \x01(\x08\x12\x13\n\x0b\x63up_holders\x18\x11 \x01(\r\x12\x16\n\x0ehas_nav_system\x18\x12 \x01(\x08\"C\n\x05Wheel\x12\x10\n\x08\x64iameter\x18\x01 \x01(\r\x12\x14\n\x0c\x61ir_pressure\x18\x02 \x01(\x02\x12\x12\n\nsnow_tires\x18\x03 \x01(\x08\"d\n\x06\x45ngine\x12\x12\n\nhorsepower\x18\x01 \x01(\r\x12\x11\n\tcylinders\x18\x02 \x01(\r\x12\n\n\x02\x63\x63\x18\x03 \x01(\r\x12\x10\n\x08uses_gas\x18\x04 \x01(\x08\x12\x15\n\ruses_electric\x18\x05 \x01(\x08*j\n\x05\x43olor\x12\t\n\x05\x42LACK\x10\x00\x12\t\n\x05WHITE\x10\x01\x12\x07\n\x03RED\x10\x02\x12\t\n\x05GREEN\x10\x03\x12\x08\n\x04\x42LUE\x10\x04\x12\x08\n\x04\x43YAN\x10\x05\x12\x0b\n\x07MAGENTA\x10\x06\x12\n\n\x06YELLOW\x10\x07\x12\n\n\x06SILVER\x10\x08')
|
||||
)
|
||||
|
||||
_COLOR = _descriptor.EnumDescriptor(
|
||||
name='Color',
|
||||
|
@ -64,6 +71,7 @@ _COLOR = _descriptor.EnumDescriptor(
|
|||
serialized_start=750,
|
||||
serialized_end=856,
|
||||
)
|
||||
_sym_db.RegisterEnumDescriptor(_COLOR)
|
||||
|
||||
Color = enum_type_wrapper.EnumTypeWrapper(_COLOR)
|
||||
BLACK = 0
|
||||
|
@ -100,7 +108,10 @@ _PARKINGLOT = _descriptor.Descriptor(
|
|||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto2',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=44,
|
||||
serialized_end=100,
|
||||
)
|
||||
|
@ -128,7 +139,10 @@ _TOTALVALUE = _descriptor.Descriptor(
|
|||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto2',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=102,
|
||||
serialized_end=130,
|
||||
)
|
||||
|
@ -144,14 +158,14 @@ _CAR = _descriptor.Descriptor(
|
|||
_descriptor.FieldDescriptor(
|
||||
name='make', full_name='capnp.benchmark.protobuf.Car.make', index=0,
|
||||
number=1, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=unicode("", "utf-8"),
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='model', full_name='capnp.benchmark.protobuf.Car.model', index=1,
|
||||
number=2, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=unicode("", "utf-8"),
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
|
@ -221,14 +235,14 @@ _CAR = _descriptor.Descriptor(
|
|||
_descriptor.FieldDescriptor(
|
||||
name='fuel_capacity', full_name='capnp.benchmark.protobuf.Car.fuel_capacity', index=11,
|
||||
number=12, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='fuel_level', full_name='capnp.benchmark.protobuf.Car.fuel_level', index=12,
|
||||
number=13, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
|
@ -275,7 +289,10 @@ _CAR = _descriptor.Descriptor(
|
|||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto2',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=133,
|
||||
serialized_end=577,
|
||||
)
|
||||
|
@ -298,7 +315,7 @@ _WHEEL = _descriptor.Descriptor(
|
|||
_descriptor.FieldDescriptor(
|
||||
name='air_pressure', full_name='capnp.benchmark.protobuf.Wheel.air_pressure', index=1,
|
||||
number=2, type=2, cpp_type=6, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
|
@ -317,7 +334,10 @@ _WHEEL = _descriptor.Descriptor(
|
|||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto2',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=579,
|
||||
serialized_end=646,
|
||||
)
|
||||
|
@ -373,7 +393,10 @@ _ENGINE = _descriptor.Descriptor(
|
|||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto2',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=648,
|
||||
serialized_end=748,
|
||||
)
|
||||
|
@ -387,36 +410,43 @@ DESCRIPTOR.message_types_by_name['TotalValue'] = _TOTALVALUE
|
|||
DESCRIPTOR.message_types_by_name['Car'] = _CAR
|
||||
DESCRIPTOR.message_types_by_name['Wheel'] = _WHEEL
|
||||
DESCRIPTOR.message_types_by_name['Engine'] = _ENGINE
|
||||
DESCRIPTOR.enum_types_by_name['Color'] = _COLOR
|
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
||||
|
||||
class ParkingLot(_message.Message):
|
||||
__metaclass__ = _reflection.GeneratedProtocolMessageType
|
||||
DESCRIPTOR = _PARKINGLOT
|
||||
|
||||
ParkingLot = _reflection.GeneratedProtocolMessageType('ParkingLot', (_message.Message,), dict(
|
||||
DESCRIPTOR = _PARKINGLOT,
|
||||
__module__ = 'carsales_pb2'
|
||||
# @@protoc_insertion_point(class_scope:capnp.benchmark.protobuf.ParkingLot)
|
||||
))
|
||||
_sym_db.RegisterMessage(ParkingLot)
|
||||
|
||||
class TotalValue(_message.Message):
|
||||
__metaclass__ = _reflection.GeneratedProtocolMessageType
|
||||
DESCRIPTOR = _TOTALVALUE
|
||||
|
||||
TotalValue = _reflection.GeneratedProtocolMessageType('TotalValue', (_message.Message,), dict(
|
||||
DESCRIPTOR = _TOTALVALUE,
|
||||
__module__ = 'carsales_pb2'
|
||||
# @@protoc_insertion_point(class_scope:capnp.benchmark.protobuf.TotalValue)
|
||||
))
|
||||
_sym_db.RegisterMessage(TotalValue)
|
||||
|
||||
class Car(_message.Message):
|
||||
__metaclass__ = _reflection.GeneratedProtocolMessageType
|
||||
DESCRIPTOR = _CAR
|
||||
|
||||
Car = _reflection.GeneratedProtocolMessageType('Car', (_message.Message,), dict(
|
||||
DESCRIPTOR = _CAR,
|
||||
__module__ = 'carsales_pb2'
|
||||
# @@protoc_insertion_point(class_scope:capnp.benchmark.protobuf.Car)
|
||||
))
|
||||
_sym_db.RegisterMessage(Car)
|
||||
|
||||
class Wheel(_message.Message):
|
||||
__metaclass__ = _reflection.GeneratedProtocolMessageType
|
||||
DESCRIPTOR = _WHEEL
|
||||
|
||||
Wheel = _reflection.GeneratedProtocolMessageType('Wheel', (_message.Message,), dict(
|
||||
DESCRIPTOR = _WHEEL,
|
||||
__module__ = 'carsales_pb2'
|
||||
# @@protoc_insertion_point(class_scope:capnp.benchmark.protobuf.Wheel)
|
||||
))
|
||||
_sym_db.RegisterMessage(Wheel)
|
||||
|
||||
class Engine(_message.Message):
|
||||
__metaclass__ = _reflection.GeneratedProtocolMessageType
|
||||
DESCRIPTOR = _ENGINE
|
||||
|
||||
Engine = _reflection.GeneratedProtocolMessageType('Engine', (_message.Message,), dict(
|
||||
DESCRIPTOR = _ENGINE,
|
||||
__module__ = 'carsales_pb2'
|
||||
# @@protoc_insertion_point(class_scope:capnp.benchmark.protobuf.Engine)
|
||||
))
|
||||
_sym_db.RegisterMessage(Engine)
|
||||
|
||||
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
|
|
|
@ -25,7 +25,7 @@ def random_car(car):
|
|||
car.length = 170 + rand_int(150)
|
||||
car.width = 48 + rand_int(36)
|
||||
car.height = 54 + rand_int(48)
|
||||
car.weight = car.length * car.width * car.height / 200
|
||||
car.weight = car.length * car.width * car.height // 200
|
||||
|
||||
engine = car.engine
|
||||
engine.horsepower = 100 * rand_int(400)
|
||||
|
@ -51,7 +51,7 @@ def calc_value(car):
|
|||
result += wheel.diameter * wheel.diameter
|
||||
result += 100 if wheel.snow_tires else 0
|
||||
|
||||
result += car.length * car.width * car.height / 50
|
||||
result += car.length * car.width * car.height // 50
|
||||
|
||||
engine = car.engine
|
||||
result += engine.horsepower * 40
|
||||
|
|
|
@ -25,7 +25,7 @@ def random_car(car):
|
|||
car.length = 170 + rand_int(150)
|
||||
car.width = 48 + rand_int(36)
|
||||
car.height = 54 + rand_int(48)
|
||||
car.weight = car.length * car.width * car.height / 200
|
||||
car.weight = car.length * car.width * car.height // 200
|
||||
|
||||
engine = car.init('engine')
|
||||
engine.horsepower = 100 * rand_int(400)
|
||||
|
@ -51,7 +51,7 @@ def calc_value(car):
|
|||
result += wheel.diameter * wheel.diameter
|
||||
result += 100 if wheel.snowTires else 0
|
||||
|
||||
result += car.length * car.width * car.height / 50
|
||||
result += car.length * car.width * car.height // 50
|
||||
|
||||
engine = car.engine
|
||||
result += engine.horsepower * 40
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package capnp.benchmark.protobuf;
|
||||
|
||||
message SearchResultList {
|
||||
|
|
|
@ -1,19 +1,26 @@
|
|||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: catrank.proto
|
||||
|
||||
import sys
|
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import message as _message
|
||||
from google.protobuf import reflection as _reflection
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf import descriptor_pb2
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor(
|
||||
name='catrank.proto',
|
||||
package='capnp.benchmark.protobuf',
|
||||
serialized_pb='\n\rcatrank.proto\x12\x18\x63\x61pnp.benchmark.protobuf\"J\n\x10SearchResultList\x12\x36\n\x06result\x18\x01 \x03(\x0b\x32&.capnp.benchmark.protobuf.SearchResult\";\n\x0cSearchResult\x12\x0b\n\x03url\x18\x01 \x01(\t\x12\r\n\x05score\x18\x02 \x01(\x01\x12\x0f\n\x07snippet\x18\x03 \x01(\t')
|
||||
syntax='proto2',
|
||||
serialized_pb=_b('\n\rcatrank.proto\x12\x18\x63\x61pnp.benchmark.protobuf\"J\n\x10SearchResultList\x12\x36\n\x06result\x18\x01 \x03(\x0b\x32&.capnp.benchmark.protobuf.SearchResult\";\n\x0cSearchResult\x12\x0b\n\x03url\x18\x01 \x01(\t\x12\r\n\x05score\x18\x02 \x01(\x01\x12\x0f\n\x07snippet\x18\x03 \x01(\t')
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
@ -40,7 +47,10 @@ _SEARCHRESULTLIST = _descriptor.Descriptor(
|
|||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto2',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=43,
|
||||
serialized_end=117,
|
||||
)
|
||||
|
@ -56,21 +66,21 @@ _SEARCHRESULT = _descriptor.Descriptor(
|
|||
_descriptor.FieldDescriptor(
|
||||
name='url', full_name='capnp.benchmark.protobuf.SearchResult.url', index=0,
|
||||
number=1, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=unicode("", "utf-8"),
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='score', full_name='capnp.benchmark.protobuf.SearchResult.score', index=1,
|
||||
number=2, type=1, cpp_type=5, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
has_default_value=False, default_value=float(0),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='snippet', full_name='capnp.benchmark.protobuf.SearchResult.snippet', index=2,
|
||||
number=3, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=unicode("", "utf-8"),
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
|
@ -82,7 +92,10 @@ _SEARCHRESULT = _descriptor.Descriptor(
|
|||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto2',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=119,
|
||||
serialized_end=178,
|
||||
)
|
||||
|
@ -90,18 +103,21 @@ _SEARCHRESULT = _descriptor.Descriptor(
|
|||
_SEARCHRESULTLIST.fields_by_name['result'].message_type = _SEARCHRESULT
|
||||
DESCRIPTOR.message_types_by_name['SearchResultList'] = _SEARCHRESULTLIST
|
||||
DESCRIPTOR.message_types_by_name['SearchResult'] = _SEARCHRESULT
|
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
||||
|
||||
class SearchResultList(_message.Message):
|
||||
__metaclass__ = _reflection.GeneratedProtocolMessageType
|
||||
DESCRIPTOR = _SEARCHRESULTLIST
|
||||
|
||||
SearchResultList = _reflection.GeneratedProtocolMessageType('SearchResultList', (_message.Message,), dict(
|
||||
DESCRIPTOR = _SEARCHRESULTLIST,
|
||||
__module__ = 'catrank_pb2'
|
||||
# @@protoc_insertion_point(class_scope:capnp.benchmark.protobuf.SearchResultList)
|
||||
))
|
||||
_sym_db.RegisterMessage(SearchResultList)
|
||||
|
||||
class SearchResult(_message.Message):
|
||||
__metaclass__ = _reflection.GeneratedProtocolMessageType
|
||||
DESCRIPTOR = _SEARCHRESULT
|
||||
|
||||
SearchResult = _reflection.GeneratedProtocolMessageType('SearchResult', (_message.Message,), dict(
|
||||
DESCRIPTOR = _SEARCHRESULT,
|
||||
__module__ = 'catrank_pb2'
|
||||
# @@protoc_insertion_point(class_scope:capnp.benchmark.protobuf.SearchResult)
|
||||
))
|
||||
_sym_db.RegisterMessage(SearchResult)
|
||||
|
||||
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
|
|
|
@ -2,8 +2,12 @@
|
|||
|
||||
from common import rand_int, rand_double, rand_bool, WORDS, from_bytes_helper
|
||||
from random import choice
|
||||
from string import letters
|
||||
from itertools import izip
|
||||
from string import ascii_letters
|
||||
try:
|
||||
# Python 2
|
||||
from itertools import izip
|
||||
except ImportError:
|
||||
izip = zip
|
||||
import catrank_pb2
|
||||
|
||||
class Benchmark:
|
||||
|
@ -22,7 +26,7 @@ class Benchmark:
|
|||
result = request.result.add()
|
||||
result.score = 1000 - i
|
||||
url_size = rand_int(100)
|
||||
result.url = "http://example.com/" + ''.join([choice(letters) for _ in range(url_size)])
|
||||
result.url = "http://example.com/" + ''.join([choice(ascii_letters) for _ in range(url_size)])
|
||||
|
||||
isCat = rand_bool()
|
||||
isDog = rand_bool()
|
||||
|
|
|
@ -4,8 +4,12 @@ import capnp
|
|||
import catrank_capnp
|
||||
from common import rand_int, rand_double, rand_bool, WORDS
|
||||
from random import choice
|
||||
from string import letters
|
||||
from itertools import izip
|
||||
from string import ascii_letters
|
||||
try:
|
||||
# Python 2
|
||||
from itertools import izip
|
||||
except ImportError:
|
||||
izip = zip
|
||||
|
||||
class Benchmark:
|
||||
def __init__(self, compression):
|
||||
|
@ -29,7 +33,7 @@ class Benchmark:
|
|||
for i, result in enumerate(results):
|
||||
result.score = 1000 - i
|
||||
url_size = rand_int(100)
|
||||
result.url = "http://example.com/" + ''.join([choice(letters) for _ in range(url_size)])
|
||||
result.url = "http://example.com/" + ''.join([choice(ascii_letters) for _ in range(url_size)])
|
||||
|
||||
isCat = rand_bool()
|
||||
isDog = rand_bool()
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package capnp.benchmark.protobuf;
|
||||
|
||||
enum Operation {
|
||||
|
|
|
@ -1,20 +1,27 @@
|
|||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: eval.proto
|
||||
|
||||
import sys
|
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
|
||||
from google.protobuf.internal import enum_type_wrapper
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import message as _message
|
||||
from google.protobuf import reflection as _reflection
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf import descriptor_pb2
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor(
|
||||
name='eval.proto',
|
||||
package='capnp.benchmark.protobuf',
|
||||
serialized_pb='\n\neval.proto\x12\x18\x63\x61pnp.benchmark.protobuf\"\xe5\x01\n\nExpression\x12/\n\x02op\x18\x01 \x02(\x0e\x32#.capnp.benchmark.protobuf.Operation\x12\x12\n\nleft_value\x18\x02 \x01(\x05\x12=\n\x0fleft_expression\x18\x03 \x01(\x0b\x32$.capnp.benchmark.protobuf.Expression\x12\x13\n\x0bright_value\x18\x04 \x01(\x05\x12>\n\x10right_expression\x18\x05 \x01(\x0b\x32$.capnp.benchmark.protobuf.Expression\"!\n\x10\x45valuationResult\x12\r\n\x05value\x18\x01 \x02(\x11*I\n\tOperation\x12\x07\n\x03\x41\x44\x44\x10\x00\x12\x0c\n\x08SUBTRACT\x10\x01\x12\x0c\n\x08MULTIPLY\x10\x02\x12\n\n\x06\x44IVIDE\x10\x03\x12\x0b\n\x07MODULUS\x10\x04')
|
||||
syntax='proto2',
|
||||
serialized_pb=_b('\n\neval.proto\x12\x18\x63\x61pnp.benchmark.protobuf\"\xe5\x01\n\nExpression\x12/\n\x02op\x18\x01 \x02(\x0e\x32#.capnp.benchmark.protobuf.Operation\x12\x12\n\nleft_value\x18\x02 \x01(\x05\x12=\n\x0fleft_expression\x18\x03 \x01(\x0b\x32$.capnp.benchmark.protobuf.Expression\x12\x13\n\x0bright_value\x18\x04 \x01(\x05\x12>\n\x10right_expression\x18\x05 \x01(\x0b\x32$.capnp.benchmark.protobuf.Expression\"!\n\x10\x45valuationResult\x12\r\n\x05value\x18\x01 \x02(\x11*I\n\tOperation\x12\x07\n\x03\x41\x44\x44\x10\x00\x12\x0c\n\x08SUBTRACT\x10\x01\x12\x0c\n\x08MULTIPLY\x10\x02\x12\n\n\x06\x44IVIDE\x10\x03\x12\x0b\n\x07MODULUS\x10\x04')
|
||||
)
|
||||
|
||||
_OPERATION = _descriptor.EnumDescriptor(
|
||||
name='Operation',
|
||||
|
@ -48,6 +55,7 @@ _OPERATION = _descriptor.EnumDescriptor(
|
|||
serialized_start=307,
|
||||
serialized_end=380,
|
||||
)
|
||||
_sym_db.RegisterEnumDescriptor(_OPERATION)
|
||||
|
||||
Operation = enum_type_wrapper.EnumTypeWrapper(_OPERATION)
|
||||
ADD = 0
|
||||
|
@ -108,7 +116,10 @@ _EXPRESSION = _descriptor.Descriptor(
|
|||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto2',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=41,
|
||||
serialized_end=270,
|
||||
)
|
||||
|
@ -136,7 +147,10 @@ _EVALUATIONRESULT = _descriptor.Descriptor(
|
|||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto2',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=272,
|
||||
serialized_end=305,
|
||||
)
|
||||
|
@ -146,18 +160,22 @@ _EXPRESSION.fields_by_name['left_expression'].message_type = _EXPRESSION
|
|||
_EXPRESSION.fields_by_name['right_expression'].message_type = _EXPRESSION
|
||||
DESCRIPTOR.message_types_by_name['Expression'] = _EXPRESSION
|
||||
DESCRIPTOR.message_types_by_name['EvaluationResult'] = _EVALUATIONRESULT
|
||||
DESCRIPTOR.enum_types_by_name['Operation'] = _OPERATION
|
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
||||
|
||||
class Expression(_message.Message):
|
||||
__metaclass__ = _reflection.GeneratedProtocolMessageType
|
||||
DESCRIPTOR = _EXPRESSION
|
||||
|
||||
Expression = _reflection.GeneratedProtocolMessageType('Expression', (_message.Message,), dict(
|
||||
DESCRIPTOR = _EXPRESSION,
|
||||
__module__ = 'eval_pb2'
|
||||
# @@protoc_insertion_point(class_scope:capnp.benchmark.protobuf.Expression)
|
||||
))
|
||||
_sym_db.RegisterMessage(Expression)
|
||||
|
||||
class EvaluationResult(_message.Message):
|
||||
__metaclass__ = _reflection.GeneratedProtocolMessageType
|
||||
DESCRIPTOR = _EVALUATIONRESULT
|
||||
|
||||
EvaluationResult = _reflection.GeneratedProtocolMessageType('EvaluationResult', (_message.Message,), dict(
|
||||
DESCRIPTOR = _EVALUATIONRESULT,
|
||||
__module__ = 'eval_pb2'
|
||||
# @@protoc_insertion_point(class_scope:capnp.benchmark.protobuf.EvaluationResult)
|
||||
))
|
||||
_sym_db.RegisterMessage(EvaluationResult)
|
||||
|
||||
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
|
|
|
@ -28,7 +28,7 @@ def div(a, b):
|
|||
if a == MIN_INT and b == -1:
|
||||
return MAX_INT
|
||||
|
||||
return a / b
|
||||
return a // b
|
||||
|
||||
def mod(a, b):
|
||||
if b == 0:
|
||||
|
@ -109,4 +109,4 @@ class Benchmark:
|
|||
response.value = evaluate_expression(request)
|
||||
|
||||
def check(self, response, expected):
|
||||
return response.value == expected
|
||||
return response.value == expected
|
||||
|
|
|
@ -29,7 +29,7 @@ def div(a, b):
|
|||
if a == MIN_INT and b == -1:
|
||||
return MAX_INT
|
||||
|
||||
return a / b
|
||||
return a // b
|
||||
|
||||
def mod(a, b):
|
||||
if b == 0:
|
||||
|
|
Loading…
Add table
Reference in a new issue