Beispiel #1
0
           'l': range(10),
           'ids': [ uuid.uuid1() for x in range(5)],
           }
## msg = SimpleMessage(type='öäü', payload=payload)
msg = TopicMessage(topic='öäü', payload=payload)

## s = SerializerBase()
s = TopicSerializer()
## s.multipart = True

# warm-up cpu
for i in xrange(1000000):
    x = float(i) * 0.333
    f = x / 1.1

t0 = time.time()
for n in xrange(COUNT):
    data = s.serialize(msg)
    m = s.deserialize(data)
t1 = time.time()
td = t1 - t0
print "%.6f" % td
tr = (td * 1000000) / COUNT
print "%.3f" % tr
print


### Local Variables:
### mode: python
### End:
Beispiel #2
0
print repr(url)
print repr(topic)

try:
    zmq_ctx = zmq.Context()

    sin = zmq_ctx.socket(zmq.SUB)
    sin.setsockopt(zmq.SUBSCRIBE, str(topic))
    sin.hwm = 10000
    ## sin.connect(url)
    sin.bind(url)

    ts = TopicSerializer()
    ts.dumps = marshal.dumps
    ts.loads = marshal.loads
    ts.multipart = True

    ## sin.recv()
    ## print 'run'

    while True:
        data = sin.recv_multipart()
        ## pprint(data)
        msg = ts.deserialize(data)
        
except KeyboardInterrupt:
    pass

print