Skip to content

Instantly share code, notes, and snippets.

@binarybana
Created April 20, 2014 00:40
Show Gist options
  • Save binarybana/11101773 to your computer and use it in GitHub Desktop.
Save binarybana/11101773 to your computer and use it in GitHub Desktop.
ZMQ.jl Ping Pong Performance Benchmark
using ZMQ
ctx = Context(1)
s = Socket(ctx, ZMQ.REQ)
ZMQ.connect(s, "tcp://localhost:7001")
gc_disable()
readline()
for i=1:20
tic()
ZMQ.send(s, "ping")
msg = ZMQ.recv(s)
toc()
end
import zmq
import time
ctx = zmq.Context()
socket = ctx.socket(zmq.REQ)
socket.connect('tcp://127.0.0.1:7001')
raw_input()
for i in range(20):
t1 = time.time()
socket.send("ping")
msg = socket.recv()
print(time.time() - t1)
import zmq
import time
ctx = zmq.Context()
socket = ctx.socket(zmq.REP)
socket.bind('tcp://*:7001')
while True:
msg = socket.recv()
socket.send("pong")
using ZMQ
ctx = Context(1)
s = Socket(ctx, ZMQ.REP)
ZMQ.bind(s, "tcp://*:7001")
while true
msg = ZMQ.recv(s)
ZMQ.send(s, "pong")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment