summaryrefslogtreecommitdiff
path: root/perf/python
diff options
context:
space:
mode:
Diffstat (limited to 'perf/python')
-rw-r--r--perf/python/local_lat.py42
-rw-r--r--perf/python/local_thr.py44
-rw-r--r--perf/python/remote_lat.py43
-rw-r--r--perf/python/remote_thr.py17
4 files changed, 62 insertions, 84 deletions
diff --git a/perf/python/local_lat.py b/perf/python/local_lat.py
index 9883dc0..7f1503f 100644
--- a/perf/python/local_lat.py
+++ b/perf/python/local_lat.py
@@ -18,50 +18,32 @@
#
import sys
-from datetime import datetime
-import libpyzmq
import time
-
+import libpyzmq
def main ():
- if len (sys.argv) != 5:
- print 'usage: py_local_lat <in-interface> <out-interface> <message-size> <roundtrip-count>'
+ if len (sys.argv) != 4:
+ print 'usage: local_lat <bind-to> <roundtrip-count> <message-size>'
sys.exit (1)
try:
- in_interface = sys.argv [1]
- out_interface = sys.argv [2]
+ bind_to = sys.argv [1]
+ roundtrip_count = int (sys.argv [2])
message_size = int (sys.argv [3])
- roundtrip_count = int (sys.argv [4])
except (ValueError, OverflowError), e:
print 'message-size and roundtrip-count must be integers'
sys.exit (1)
- print "message size:", message_size, "[B]"
- print "roundtrip count:", roundtrip_count
+ ctx = libpyzmq.Context (1, 1);
+ s = libpyzmq.Socket (ctx, libpyzmq.REP)
+ s.bind (bind_to)
- z = libpyzmq.Zmq ()
- context = z.context (1,1);
-
- in_socket = z.socket (context, libpyzmq.ZMQ_SUB)
- out_socket = z.socket (context, libpyzmq.ZMQ_PUB)
-
- z.bind (in_socket, addr = in_interface)
- z.bind (out_socket, addr = out_interface)
-
- msg_out = z.init_msg_data (string_msg, type)
-
- start = datetime.now ()
for i in range (0, roundtrip_count):
- z.send (out_socket, msg_out, True)
- list = z.receive (in_socket, True)
- msg_in = list [1]
- assert len(msg_in) == message_size
- end = datetime.now ()
+ msg = s.recv ()
+ assert len (msg) == message_size
+ s.send (msg)
- delta = end - start
- delta_us = delta.seconds * 1000000 + delta.microseconds
- print 'Your average latency is', delta_us / roundtrip_count, ' [us]'
+ time.sleep (1)
if __name__ == "__main__":
main ()
diff --git a/perf/python/local_thr.py b/perf/python/local_thr.py
index 9b199df..6113c82 100644
--- a/perf/python/local_thr.py
+++ b/perf/python/local_thr.py
@@ -23,46 +23,42 @@ import libpyzmq
def main ():
if len (sys.argv) != 4:
- print ('usage: py_local_thr <in_interface> <message-size> ' +
- '<message-count>')
+ print 'usage: local_thr <bind-to> <message-size> <message-count>'
sys.exit (1)
try:
+ bind_to = sys.argv [1]
message_size = int (sys.argv [2])
message_count = int (sys.argv [3])
except (ValueError, OverflowError), e:
print 'message-size and message-count must be integers'
sys.exit (1)
- print "message size:", message_size, "[B]"
- print "message count:", message_count
+ ctx = libpyzmq.Context (1, 1);
+ s = libpyzmq.Socket (ctx, libpyzmq.P2P)
+ s.bind (bind_to)
- z = libpyzmq.Zmq ()
+ msg = s.recv ()
+ assert len (msg) == message_size
- context = z.context (1,1)
- in_socket = z.socket (context, libpyzmq.ZMQ_SUB)
- z.connect (in_socketaddr = sys.argv [1])
-
-
- list = z.receive (in_socket, True)
- msg = list [1]
- assert len(msg) == message_size
start = datetime.now ()
+
for i in range (1, message_count):
- list = z.receive (in_socket, True)
- msg = list [1]
- assert len(msg) == message_size
+ msg = s.recv ()
+ assert len (msg) == message_size
+
end = datetime.now()
- delta = end - start
- delta_us = delta.seconds * 1000000 + delta.microseconds
- if delta_us == 0:
- delta_us = 1
- message_thr = (1000000.0 * float (message_count)) / float (delta_us)
- megabit_thr = (message_thr * float (message_size) * 8.0) / 1000000.0;
+ elapsed = (end - start).seconds * 1000000 + (end - start).microseconds
+ if elapsed == 0:
+ elapsed = 1
+ throughput = (1000000.0 * float (message_count)) / float (elapsed)
+ megabits = float (throughput * message_size * 8) / 1000000
- print "Your average throughput is %.0f [msg/s]" % (message_thr, )
- print "Your average throughput is %.2f [Mb/s]" % (megabit_thr, )
+ print "message size: %.0f [B]" % (message_size, )
+ print "message count: %.0f" % (message_count, )
+ print "mean throughput: %.0f [msg/s]" % (throughput, )
+ print "mean throughput: %.3f [Mb/s]" % (megabits, )
if __name__ == "__main__":
main ()
diff --git a/perf/python/remote_lat.py b/perf/python/remote_lat.py
index ac73595..372f567 100644
--- a/perf/python/remote_lat.py
+++ b/perf/python/remote_lat.py
@@ -20,39 +20,40 @@
import sys
from datetime import datetime
import libpyzmq
-import time
-
def main ():
- if len(sys.argv) != 5:
- print ('usage: py_remote_lat <in-interface> ' +
- '<out-interface> <message-size> <roundtrip-count>')
+ if len(sys.argv) != 4:
+ print 'usage: remote_lat <connect-to> <roundtrip-count> <message-size>'
sys.exit (1)
try:
- message_size = int (sys.argv [3])
- roundtrip_count = int (sys.argv [4])
+ connect_to = sys.argv [1]
+ message_size = int (sys.argv [2])
+ roundtrip_count = int (sys.argv [3])
except (ValueError, OverflowError), e:
print 'message-size and message-count must be integers'
sys.exit (1)
- z = libpyzmq.Zmq ()
+ ctx = libpyzmq.Context (1, 1);
+ s = libpyzmq.Socket (ctx, libpyzmq.REQ)
+ s.connect (connect_to)
+
+ msg = ''.join ([' ' for n in range (0, message_size)])
+
+ start = datetime.now ()
- context = z.context (1,1)
-
- in_socket = z.socket (context, libpyzmq.ZMQ_SUB)
- out_socket = z.socket (context, libpyzmq.ZMQ_PUB)
-
- z.connect (in_socket, addr = in_interface)
- z.connect (out_socket, addr = out_interface)
-
for i in range (0, roundtrip_count):
- list = z.receive (in_socket, True)
- message = list [1]
- z.send (out_socket, message, True)
-
- time.sleep (2)
+ s.send (msg)
+ msg = s.recv ()
+ assert len (msg) == message_size
+
+ end = datetime.now ()
+ delta = (end - start).microseconds + 1000000 * (end - start).seconds
+ latency = delta / roundtrip_count / 2
+ print "message size: %.0f [B]" % (message_size, )
+ print "roundtrip count: %.0f" % (roundtrip_count, )
+ print "mean latency: %.3f [us]" % (latency, )
if __name__ == "__main__":
main ()
diff --git a/perf/python/remote_thr.py b/perf/python/remote_thr.py
index a4f2b66..a80adfd 100644
--- a/perf/python/remote_thr.py
+++ b/perf/python/remote_thr.py
@@ -18,33 +18,32 @@
#
import sys
-from datetime import datetime
import libpyzmq
import time
def main ():
if len (sys.argv) != 4:
- print 'usage: py_remote_thr <out-interface> <message-size> <message-count>'
+ print 'usage: remote_thr <connect-to> <message-size> <message-count>'
sys.exit (1)
try:
+ connect_to = argv [1]
message_size = int (sys.argv [2])
message_count = int (sys.argv [3])
except (ValueError, OverflowError), e:
print 'message-size and message-count must be integers'
sys.exit (1)
- z = libpyzmq.Zmq ()
- context = z.context (1,1);
- out_socket = z.socket (context, libpyzmq.ZMQ_PUB)
- z.bind (out_socket, addr = sys.argv [1])
+ ctx = libpyzmq.Context (1, 1);
+ s = libpyzmq.Socket (ctx, libpyzmq.P2P)
+ s.connect (connect_to)
- msg = z.init_msg_data (string_msg, type)
+ msg = ''.join ([' ' for n in range (0, message_size)])
for i in range (0, message_count):
- z.send (out_socket, msg, True)
+ s.send (msg)
- time.sleep (2)
+ time.sleep (10)
if __name__ == "__main__":
main ()