Exemplo n.º 1
0
def encode(n, proto_factory=TBinaryProtocolFactory()):
    ab = make_addressbook()
    start = time.time()
    for i in range(n):
        serialize(ab, proto_factory)
    end = time.time()
    print("encode\t-> {}".format(end - start))
Exemplo n.º 2
0
def encode(n, proto_factory=TBinaryProtocolFactory()):
    ab = make_addressbook()
    start = time.time()
    for i in range(n):
        serialize(ab, proto_factory)
    end = time.time()
    print("encode\t-> {}".format(end - start))
Exemplo n.º 3
0
def test_mix_item():
    x_item = container.MixItem()
    x_item.list_map = [{'foo': 'bar'}]
    x_item.map_list = {'foo': ['hello', 'world']}

    x_item2 = deserialize(container.MixItem(), serialize(x_item))
    assert x_item == x_item2
Exemplo n.º 4
0
def test_map_item():
    m_item = container.MapItem()
    m_item.map_string = {'foo': 'bar'}
    m_item.map_map_string = {'foo': {'hello': 'world'}}

    m_item2 = deserialize(container.MapItem(), serialize(m_item))
    assert m_item == m_item2
Exemplo n.º 5
0
def test_list_item():
    l_item = container.ListItem()
    l_item.list_string = ['foo', 'bar']
    l_item.list_list_string = [['foo', 'bar']]

    b = serialize(l_item)
    l_item2 = deserialize(container.ListItem(), b)
    assert l_item == l_item2
Exemplo n.º 6
0
def test_mix_item():
    x_item = container.MixItem()
    x_item.list_map = [{"foo": "bar"}]
    x_item.map_list = {"foo": ["hello", "world"]}

    b = serialize(x_item)
    x_item2 = deserialize(container.MixItem(), b)
    assert x_item == x_item2
Exemplo n.º 7
0
def test_map_item():
    m_item = container.MapItem()
    m_item.map_string = {"foo": "bar"}
    m_item.map_map_string = {"foo": {"hello": "world"}}

    b = serialize(m_item)
    m_item2 = deserialize(container.MapItem(), b)
    assert m_item == m_item2
Exemplo n.º 8
0
def test_list_item():
    l_item = container.ListItem()
    l_item.list_string = ["foo", "bar"]
    l_item.list_list_string = [["foo", "bar"]]

    b = serialize(l_item)
    l_item2 = deserialize(container.ListItem(), b)
    assert l_item == l_item2
Exemplo n.º 9
0
def test_list_struct():
    l_item = container.ListItem()
    l_item.list_string = ['foo', 'bar'] * 100
    l_item.list_list_string = [['foo', 'bar']] * 100

    l_struct = container.ListStruct()
    l_struct.list_items = [l_item] * 100

    b = serialize(l_struct)
    l_struct2 = deserialize(container.ListStruct(), b)
    assert l_struct == l_struct2
Exemplo n.º 10
0
def decode(n, proto_factory=TBinaryProtocolFactory()):
    ab = make_addressbook()
    encoded = serialize(ab)
    for i in range(n):
        deserialize(ab, encoded, proto_factory)
Exemplo n.º 11
0
def encode(n, proto_factory=TBinaryProtocolFactory()):
    for i in range(n):
        ab = make_addressbook()
        serialize(ab, proto_factory)
Exemplo n.º 12
0
def decode(n, proto_factory=TBinaryProtocolFactory()):
    ab = make_addressbook()
    encoded = serialize(ab)
    for i in range(n):
        deserialize(ab, encoded, proto_factory)
Exemplo n.º 13
0
def encode(n, proto_factory=TBinaryProtocolFactory()):
    for i in range(n):
        ab = make_addressbook()
        serialize(ab, proto_factory)
Exemplo n.º 14
0
    phone1.type = addressbook.PhoneType.MOBILE
    phone1.number = b'555-1212'
    phone2 = addressbook.PhoneNumber()
    phone2.type = addressbook.PhoneType.HOME
    phone2.number = b'555-1234'
    person = addressbook.Person()
    person.name = b"Alice"
    person.phones = [phone1, phone2]
    person.created_at = 1400000000

    ab = addressbook.AddressBook()
    ab.people = {person.name: person}
    return ab


ab_encoded = serialize(make_addressbook())


def encode(n, proto_factory=TBinaryProtocolFactory()):
    ab = make_addressbook()
    start = time.time()
    for i in range(n):
        serialize(ab, proto_factory)
    end = time.time()
    print("encode\t-> {}".format(end - start))


def decode(n, proto_factory=TBinaryProtocolFactory()):
    ab = addressbook.AddressBook()
    start = time.time()
    for i in range(n):
Exemplo n.º 15
0
def make_addressbook():
    phone1 = addressbook.PhoneNumber()
    phone1.type = addressbook.PhoneType.MOBILE
    phone1.number = b'555-1212'
    phone2 = addressbook.PhoneNumber()
    phone2.type = addressbook.PhoneType.HOME
    phone2.number = b'555-1234'
    person = addressbook.Person()
    person.name = b"Alice"
    person.phones = [phone1, phone2]
    person.created_at = 1400000000

    ab = addressbook.AddressBook()
    ab.people = {person.name: person}
    return ab
ab_encoded = serialize(make_addressbook())


def encode(n, proto_factory=TBinaryProtocolFactory()):
    ab = make_addressbook()
    start = time.time()
    for i in range(n):
        serialize(ab, proto_factory)
    end = time.time()
    print("encode\t-> {}".format(end - start))


def decode(n, proto_factory=TBinaryProtocolFactory()):
    ab = addressbook.AddressBook()
    start = time.time()
    for i in range(n):