Permalink
Browse files

implement the INPROC-THR benchmark

  • Loading branch information...
1 parent e2349bf commit 85d4766999b0442d8b86a3d93d0d7dd884eeb58f @galdor galdor committed Oct 5, 2011
Showing with 36 additions and 2 deletions.
  1. +33 −0 examples/official-benchmarks.lisp
  2. +2 −1 examples/packages.lisp
  3. +1 −1 zmq-examples.asd
@@ -62,3 +62,36 @@
(format t "message size: ~A [B]~%" message-size)
(format t "roundtrip count: ~A~%" roundtrip-count)
(format t "average latency: ~,3F [us]~%" latency))))))
+
+(defun inproc-thr (message-size message-count)
+ (zmq:with-context (context 1)
+ (zmq:with-socket (socket context :sub)
+ (zmq:setsockopt socket :subscribe "")
+ (zmq:bind socket "inproc://thr_test")
+ (let ((thread (bordeaux-threads:make-thread
+ (lambda ()
+ (zmq:with-socket (socket context :pub)
+ (zmq:connect socket "inproc://thr_test")
+ (do ((i 0 (1+ i)))
+ ((= i message-count))
+ (zmq:with-msg-init-size (message message-size)
+ (zmq:send socket message))))))))
+ (zmq:with-msg-init (message)
+ (zmq:recv socket message)
+ (unless (eq (zmq:msg-size message) message-size)
+ (error "Message of incorrect size ~A received."
+ (zmq:msg-size message)))
+ (let* ((elapsed-time (zmq:with-stopwatch
+ (do ((i 0 (1+ i)))
+ ((= i (- message-count 1)))
+ (zmq:recv socket message)
+ (unless (eq (zmq:msg-size message) message-size)
+ (error "Message of incorrect size ~A received."
+ (zmq:msg-size message))))))
+ (throughput (* (/ message-count elapsed-time) 1000000))
+ (megabits (/ (* throughput message-size 8) 1000000)))
+ (format t "message count: ~A~%" message-count)
+ (format t "message size: ~A [B]~%" message-size)
+ (format t "mean throughput ~A [msg/s]~%" (round throughput))
+ (format t "mean throughput ~,3F [Mb/s]~%" (round megabits))))
+ (bordeaux-threads:join-thread thread)))))
@@ -3,4 +3,5 @@
(:nicknames :zmq-examples)
(:use :cl)
(:export :local-thr :remote-thr
- :local-lat))
+ :local-lat :remote-lat
+ :inproc-thr))
View
@@ -4,7 +4,7 @@
:author "Nicolas Martyanoff"
:license "BSD"
:description "Examples for the zmq binding."
- :depends-on (:zmq)
+ :depends-on (:zmq :bordeaux-threads)
:components ((:module "examples"
:components ((:file "packages")
(:file "official-benchmarks"

0 comments on commit 85d4766

Please sign in to comment.