Commits

Boris FELD  committed 308e0cc

Add benchmarks

  • Participants
  • Parent commits e083f7c

Comments (0)

Files changed (11)

File benchmark/test_1/README

+Test 1: Direct communication
+
+How to run:
+-----------
+
+X is the number of messages to send
+Launch receiver: python receiver.py X
+Then start sender: python sender.py X
+
+Message is 'Hi'
+
+Result
+------
+Start at 1353789338.11
+End at 1353789357.65
+
+Temps: 19.54 secondes pour 1 million de messages

File benchmark/test_1/receiver.py

+import zmq
+import time
+import sys
+
+context = zmq.Context()
+sender = context.socket(zmq.DEALER)
+sender.connect('tcp://127.0.0.1:11111')
+
+print "Ready", time.time()
+i = 0
+while i < int(sys.argv[1]):
+    sender.recv()
+    i += 1
+print "End at", time.time()

File benchmark/test_1/sender.py

+import zmq
+import time
+import sys
+
+context = zmq.Context()
+sender = context.socket(zmq.DEALER)
+sender.bind('tcp://127.0.0.1:11111')
+
+message = 'Hi'
+
+print "Start at", time.time()
+for i in xrange(int(sys.argv[1])):
+    sender.send(message)

File benchmark/test_2/README

+Test 2, Pub-Sub same topic
+
+How to run:
+-----------
+
+X is the number of messages to send
+Launch receiver: python publisher.py X
+Then start sender: python subscriber.py X
+
+Message is 'Hi' with topic 'sample'
+
+Result
+------
+1 publisher and 1 subscriber
+
+Start at 1353792828.51
+End at 1353792910.34
+
+Temps: 81.83 secondes pour 1 million de messages (avec ~ 400 messages de perdus si pas de traitement dans la boucle)
+
+1 publisher and 3 subscriber (tous les subscribers s'abonnent au même topic)
+
+Start at 1353793489.66
+End at 1353793613.42
+
+Temps: 123.76 (nombreux drops due à saturation des CPU)

File benchmark/test_2/publisher.py

+import zmq
+import time
+import sys
+
+context = zmq.Context()
+publisher = context.socket(zmq.PUB)
+publisher.bind('tcp://127.0.0.1:11112')
+
+publisher.send('')
+time.sleep(2)
+
+message = ['sample', 'Hi']
+
+print "Start at", time.time()
+for i in xrange(int(sys.argv[1])):
+    publisher.send_multipart(message)
+print "End at", time.time()

File benchmark/test_2/subscriber.py

+import zmq
+import time
+import sys
+
+context = zmq.Context()
+subscriber = context.socket(zmq.SUB)
+subscriber.setsockopt(zmq.SUBSCRIBE, 'sample')
+subscriber.connect('tcp://127.0.0.1:11112')
+
+print "Ready", time.time()
+i = 0
+while i < int(sys.argv[1]):
+    subscriber.recv_multipart()
+    i += 1
+print "End at", time.time()

File benchmark/test_3/README

+Test 3, Pub-Sub different topic
+1 publisher, send sample1 and sample2
+1 subscriber, subscribe to sample1
+1 subscriber, subscribe to sample2
+1 subscriber, subscribe to sample1 and sample2
+
+How to run:
+-----------
+
+X is the number of messages to send
+Launch receiver: python publisher.py X
+Then start sender: python subscriber{1,2,3}.py X
+
+Message is 'Hi' with topic 'sample'
+
+Result
+------
+
+Start at 1353794175.3
+End at 1353794272.85
+
+Temps: 97.55 secondes pour 1 million de messages (avec messages perdus)

File benchmark/test_3/publisher.py

+import zmq
+import time
+import sys
+
+context = zmq.Context()
+publisher = context.socket(zmq.PUB)
+publisher.bind('tcp://127.0.0.1:11112')
+
+publisher.send('')
+time.sleep(2)
+
+message = ['sample1', 'Hi']
+message2 = ['sample2', 'Hi']
+
+print "Start at", time.time()
+for i in xrange(int(sys.argv[1])/2):
+    publisher.send_multipart(message)
+    publisher.send_multipart(message2)
+print "End at", time.time()

File benchmark/test_3/subscriber1.py

+import zmq
+import time
+import sys
+
+context = zmq.Context()
+subscriber = context.socket(zmq.SUB)
+subscriber.setsockopt(zmq.SUBSCRIBE, 'sample1')
+subscriber.connect('tcp://127.0.0.1:11112')
+
+print "Ready", time.time()
+i = 0
+while i < int(sys.argv[1]):
+    subscriber.recv_multipart()
+    i += 1
+print "End at", time.time()

File benchmark/test_3/subscriber2.py

+import zmq
+import time
+import sys
+
+context = zmq.Context()
+subscriber = context.socket(zmq.SUB)
+subscriber.setsockopt(zmq.SUBSCRIBE, 'sample2')
+subscriber.connect('tcp://127.0.0.1:11112')
+
+print "Ready", time.time()
+i = 0
+while i < int(sys.argv[1]):
+    subscriber.recv_multipart()
+    i += 1
+print "End at", time.time()

File benchmark/test_3/subscriber3.py

+import zmq
+import time
+import sys
+
+context = zmq.Context()
+subscriber = context.socket(zmq.SUB)
+subscriber.setsockopt(zmq.SUBSCRIBE, 'sample1')
+subscriber.setsockopt(zmq.SUBSCRIBE, 'sample2')
+subscriber.connect('tcp://127.0.0.1:11112')
+
+print "Ready", time.time()
+i = 0
+while i < int(sys.argv[1]):
+    subscriber.recv_multipart()
+    i += 1
+print "End at", time.time()