Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge commit 'rocha/master'

  • Loading branch information...
commit 1ec2873ae2e4aa1386be86d4209ccb6926d6d2d1 2 parents a4b681c + 73e31d6
@ellisonbg ellisonbg authored
View
31 perf/local_lat.py
@@ -21,9 +21,13 @@
import time
import zmq
-def main ():
+def main():
+ use_poll = '-p' in sys.argv
+ if use_poll:
+ sys.argv.remove('-p')
+
if len (sys.argv) != 4:
- print 'usage: local_lat <bind-to> <message-size> <roundtrip-count>'
+ print 'usage: local_lat [-p use-poll] <bind-to> <message-size> <roundtrip-count>'
sys.exit (1)
try:
@@ -34,16 +38,27 @@ def main ():
print 'message-size and roundtrip-count must be integers'
sys.exit (1)
- ctx = zmq.Context (1, 1);
+ ctx = zmq.Context (1, 1, zmq.POLL if use_poll else 0)
s = zmq.Socket (ctx, zmq.REP)
+
+ if use_poll:
+ print 'using poll'
+ p = zmq.Poller()
+ p.register(s)
+
s.bind (bind_to)
for i in range (0, roundtrip_count):
- msg = s.recv ()
+ if use_poll:
+ res = p.poll()
+ assert(res[0][1] & zmq.POLLIN)
+ msg = s.recv(zmq.NOBLOCK if use_poll else 0)
assert len (msg) == message_size
- s.send (msg)
- time.sleep (1)
+ if use_poll:
+ res = p.poll()
+ assert(res[0][1] & zmq.POLLOUT)
+ s.send(msg, zmq.NOBLOCK if use_poll else 0)
-if __name__ == "__main__":
- main ()
+if __name__ == '__main__':
+ main()
View
23 perf/local_thr.py
@@ -22,8 +22,12 @@
import zmq
def main ():
+ use_poll = '-p' in sys.argv
+ if use_poll:
+ sys.argv.remove('-p')
+
if len (sys.argv) != 4:
- print 'usage: local_thr <bind-to> <message-size> <message-count>'
+ print 'usage: local_thr [-p use-poll] <bind-to> <message-size> <message-count>'
sys.exit (1)
try:
@@ -34,13 +38,17 @@ def main ():
print 'message-size and message-count must be integers'
sys.exit (1)
- ctx = zmq.Context (1, 1);
+ ctx = zmq.Context (1, 1, zmq.POLL if use_poll else 0)
s = zmq.Socket (ctx, zmq.SUB)
- s.setsockopt (zmq.SUBSCRIBE , "");
-
# Add your socket options here.
# For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
+ s.setsockopt (zmq.SUBSCRIBE , "");
+
+ if use_poll:
+ print 'using poll'
+ p = zmq.Poller()
+ p.register(s)
s.bind (bind_to)
@@ -50,9 +58,12 @@ def main ():
start = time.clock ()
for i in range (1, message_count):
- msg = s.recv ()
+ if use_poll:
+ res = p.poll()
+ assert(res[0][1] & zmq.POLLIN)
+ msg = s.recv(zmq.NOBLOCK if use_poll else 0)
assert len (msg) == message_size
-
+
end = time.clock ()
elapsed = (end - start) * 1000000
View
29 perf/remote_lat.py
@@ -22,8 +22,12 @@
import zmq
def main ():
+ use_poll = '-p' in sys.argv
+ if use_poll:
+ sys.argv.remove('-p')
+
if len(sys.argv) != 4:
- print 'usage: remote_lat <connect-to> <message-size> <roundtrip-count>'
+ print 'usage: remote_lat [-p use-poll] <connect-to> <message-size> <roundtrip-count>'
sys.exit (1)
try:
@@ -34,22 +38,35 @@ def main ():
print 'message-size and message-count must be integers'
sys.exit (1)
- ctx = zmq.Context (1, 1);
+ ctx = zmq.Context (1, 1, zmq.POLL if use_poll else 0)
s = zmq.Socket (ctx, zmq.REQ)
print connect_to
s.connect (connect_to)
- msg = ''.join ([' ' for n in range (0, message_size)])
+ if use_poll:
+ p = zmq.Poller()
+ p.register(s)
+
+ msg = ' ' * message_size
start = time.clock ()
for i in range (0, roundtrip_count):
- s.send (msg)
- msg = s.recv ()
+ if use_poll:
+ res = p.poll()
+ assert(res[0][1] & zmq.POLLOUT)
+ s.send (msg, zmq.NOBLOCK if use_poll else 0)
+
+ if use_poll:
+ res = p.poll()
+ assert(res[0][1] & zmq.POLLIN)
+ msg = s.recv(zmq.NOBLOCK if use_poll else 0)
assert len (msg) == message_size
end = time.clock ()
+ time.sleep(1)
+
elapsed = (end - start) * 1000000
latency = elapsed / roundtrip_count / 2
@@ -59,4 +76,4 @@ def main ():
if __name__ == "__main__":
main ()
-
+
View
22 perf/remote_thr.py
@@ -22,8 +22,12 @@
import time
def main ():
+ use_poll = '-p' in sys.argv
+ if use_poll:
+ sys.argv.remove('-p')
+
if len (sys.argv) != 4:
- print 'usage: remote_thr <connect-to> <message-size> <message-count>'
+ print 'usage: remote_thr [-p use-poll] <connect-to> <message-size> <message-count>'
sys.exit (1)
try:
@@ -34,20 +38,28 @@ def main ():
print 'message-size and message-count must be integers'
sys.exit (1)
- ctx = zmq.Context (1, 1);
+ ctx = zmq.Context (1, 1, zmq.POLL if use_poll else 0)
s = zmq.Socket (ctx, zmq.PUB)
# Add your socket options here.
# For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
+ if use_poll:
+ print 'using poll'
+ p = zmq.Poller()
+ p.register(s)
+
s.connect (connect_to)
- msg = ''.join ([' ' for n in range (0, message_size)])
+ msg = ' ' * message_size
for i in range (0, message_count):
- s.send (msg)
+ if use_poll:
+ res = p.poll()
+ assert(res[0][1] & zmq.POLLOUT)
+ s.send (msg, zmq.NOBLOCK if use_poll else 0)
- time.sleep (10)
+ time.sleep (1)
if __name__ == "__main__":
main ()
View
3  setup.py
@@ -59,10 +59,11 @@
setup(
name = "pyzmq",
version = "0.1",
+ packages = ['zmq'],
ext_modules = [zmq],
author = "Brian E. Granger",
author_email = "ellisonbg@gmail.com",
description = "Cython based Python bindings for 0MQ.",
license = "LGPL",
cmdclass = cmdclass
-)
+)
Please sign in to comment.
Something went wrong with that request. Please try again.