示例#1
0
文件: bench.py 项目: PawelMarc/palm
def runpb():
    t = time.time()
    for x in xrange(10000):
        STest().ParseFromString(b)
    print 'PB, 10,000 decodes:', time.time() - t

    t = time.time()
    p = STest()
    p.ParseFromString(b)

    for x in xrange(10000):
        p.a = x
        p.SerializeToString()
    print 'PB, 10,000 encodes:', time.time() - t
示例#2
0
def encode():
    for i in range(500):
        t = Test()
        t.a = 2147483647
        t.b = 9223372036854775807
        t.c = 2147483647
        t.d = 9223372036854775807
        t.e = 4294967295
        t.f = 18446744073709551615
        t.g = 2147483647
        t.h = 9223372036854775807
        t.i = 0.3
        t.j = 0.3
        t.k = 4294967295
        t.l = 18446744073709551615
        t.m = u'测试'
        t.n = True
        t.o.a = 150
        t.o.b = -150
        t.p.append(1)
        t.p.append(2)
        t.p.append(3)
        t.q.append(1)
        t.q.append(2)
        t.q.append(3)
        r = t.r.add()
        r.a = 150
        r.b = -150
        r = t.r.add()
        r.a = 150
        r.b = -150
        t.s = TYPE2
        t.SerializeToString()
示例#3
0
文件: gen.py 项目: theHeftyFine/palm
from test_pb2 import Test

t = Test(
    sha1="thesha",
    a=911111,
    b=-911111,
    c=-911111,
    d=911111111111111,
    e=-911111111111111,
    f=-911111111111111,
)
t.bars.append(8)
t.bars.append(5)
t.bars.append(0)
print t
open("gen", "wb").write(t.SerializeToString())
示例#4
0
def decode():
    bs = '\x08\xff\xff\xff\xff\x07\x10\xff\xff\xff\xff\xff\xff\xff\xff\x7f\x18\xfe\xff\xff\xff\x0f \xfe\xff\xff\xff\xff\xff\xff\xff\xff\x01-\xff\xff\xff\xff1\xff\xff\xff\xff\xff\xff\xff\xff=\xff\xff\xff\x7fA\xff\xff\xff\xff\xff\xff\xff\x7fM\x9a\x99\x99>Q333333\xd3?X\xff\xff\xff\xff\x0f`\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01j\x06\xe6\xb5\x8b\xe8\xaf\x95p\x01z\x06\x08\x96\x01\x10\xab\x02\x80\x01\x01\x80\x01\x02\x80\x01\x03\x8a\x01\x03\x01\x02\x03\x92\x01\x06\x08\x96\x01\x10\xab\x02\x92\x01\x06\x08\x96\x01\x10\xab\x02'
    for i in range(500):
        t = Test()
        t.ParseFromString(bs)
示例#5
0
def encode():
    for i in range(500):
        t = Test()
        t.a = 2147483647
        t.b = 9223372036854775807
        t.c = 2147483647
        t.d = 9223372036854775807
        t.e = 4294967295
        t.f = 18446744073709551615
        t.g = 2147483647
        t.h = 9223372036854775807
        t.i = 0.3
        t.j = 0.3
        t.k = 4294967295
        t.l = 18446744073709551615
        t.m = u'测试'
        t.n = True
        t.o.a = 150
        t.o.b = -150
        t.p.append(1)
        t.p.append(2)
        t.p.append(3)
        t.q.append(1)
        t.q.append(2)
        t.q.append(3)
        r = t.r.add()
        r.a = 150
        r.b = -150
        r = t.r.add()
        r.a = 150
        r.b = -150
        t.s = TYPE2
        t.SerializeToString()