Permalink
Browse files

implement the INPROC-LAT benchmark

  • Loading branch information...
1 parent 85d4766 commit 831223a740273740b43cb2a15b7395c6048b99e1 @galdor galdor committed Oct 5, 2011
Showing with 29 additions and 1 deletion.
  1. +28 −0 examples/official-benchmarks.lisp
  2. +1 −1 examples/packages.lisp
@@ -95,3 +95,31 @@
(format t "mean throughput ~A [msg/s]~%" (round throughput))
(format t "mean throughput ~,3F [Mb/s]~%" (round megabits))))
(bordeaux-threads:join-thread thread)))))
+
+(defun inproc-lat (message-size roundtrip-count)
+ (zmq:with-context (context 1)
+ (zmq:with-socket (socket context :req)
+ (zmq:bind socket "inproc://lat_test")
+ (let ((thread (bordeaux-threads:make-thread
+ (lambda ()
+ (zmq:with-socket (socket context :rep)
+ (zmq:connect socket "inproc://lat_test")
+ (zmq:with-msg-init (message)
+ (do ((i 0 (1+ i)))
+ ((= i roundtrip-count))
+ (zmq:recv socket message)
+ (zmq:send socket message))))))))
+ (zmq:with-msg-init-size (message message-size)
+ (let* ((elapsed-time (zmq:with-stopwatch
+ (do ((i 0 (1+ i)))
+ ((= i roundtrip-count))
+ (zmq:send socket message)
+ (zmq:recv socket message)
+ (unless (eq (zmq:msg-size message) message-size)
+ (error "Message of incorrect size ~A received."
+ (zmq:msg-size message))))))
+ (latency (/ elapsed-time (* roundtrip-count 2))))
+ (format t "message size: ~A [B]~%" message-size)
+ (format t "roundtrip count: ~A~%" roundtrip-count)
+ (format t "average latency: ~,3F [us]~%" latency)))
+ (bordeaux-threads:join-thread thread)))))
@@ -4,4 +4,4 @@
(:use :cl)
(:export :local-thr :remote-thr
:local-lat :remote-lat
- :inproc-thr))
+ :inproc-thr :inproc-lat))

0 comments on commit 831223a

Please sign in to comment.