Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

implement the INPROC-THR benchmark

  • Loading branch information...
commit 85d4766999b0442d8b86a3d93d0d7dd884eeb58f 1 parent e2349bf
Nicolas Martyanoff authored October 05, 2011
33  examples/official-benchmarks.lisp
@@ -62,3 +62,36 @@
62 62
           (format t "message size: ~A [B]~%" message-size)
63 63
           (format t "roundtrip count: ~A~%" roundtrip-count)
64 64
           (format t "average latency: ~,3F [us]~%" latency))))))
  65
+
  66
+(defun inproc-thr (message-size message-count)
  67
+  (zmq:with-context (context 1)
  68
+    (zmq:with-socket (socket context :sub)
  69
+      (zmq:setsockopt socket :subscribe "")
  70
+      (zmq:bind socket "inproc://thr_test")
  71
+      (let ((thread (bordeaux-threads:make-thread
  72
+                     (lambda ()
  73
+                       (zmq:with-socket (socket context :pub)
  74
+                         (zmq:connect socket "inproc://thr_test")
  75
+                         (do ((i 0 (1+ i)))
  76
+                             ((= i message-count))
  77
+                           (zmq:with-msg-init-size (message message-size)
  78
+                             (zmq:send socket message))))))))
  79
+        (zmq:with-msg-init (message)
  80
+          (zmq:recv socket message)
  81
+          (unless (eq (zmq:msg-size message) message-size)
  82
+            (error "Message of incorrect size ~A received."
  83
+                   (zmq:msg-size message)))
  84
+          (let* ((elapsed-time (zmq:with-stopwatch
  85
+                                 (do ((i 0 (1+ i)))
  86
+                                     ((= i (- message-count 1)))
  87
+                                   (zmq:recv socket message)
  88
+                                   (unless (eq (zmq:msg-size message) message-size)
  89
+                                     (error "Message of incorrect size ~A received."
  90
+                                            (zmq:msg-size message))))))
  91
+                 (throughput (* (/ message-count elapsed-time) 1000000))
  92
+                 (megabits (/ (* throughput message-size 8) 1000000)))
  93
+            (format t "message count: ~A~%" message-count)
  94
+            (format t "message size: ~A [B]~%" message-size)
  95
+            (format t "mean throughput ~A [msg/s]~%" (round throughput))
  96
+            (format t "mean throughput ~,3F [Mb/s]~%" (round megabits))))
  97
+        (bordeaux-threads:join-thread thread)))))
3  examples/packages.lisp
@@ -3,4 +3,5 @@
3 3
   (:nicknames :zmq-examples)
4 4
   (:use :cl)
5 5
   (:export :local-thr :remote-thr
6  
-           :local-lat))
  6
+           :local-lat :remote-lat
  7
+           :inproc-thr))
2  zmq-examples.asd
@@ -4,7 +4,7 @@
4 4
   :author "Nicolas Martyanoff"
5 5
   :license "BSD"
6 6
   :description "Examples for the zmq binding."
7  
-  :depends-on (:zmq)
  7
+  :depends-on (:zmq :bordeaux-threads)
8 8
   :components ((:module "examples"
9 9
                 :components ((:file "packages")
10 10
                              (:file "official-benchmarks"

0 notes on commit 85d4766

Please sign in to comment.
Something went wrong with that request. Please try again.