-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbench.lisp
27 lines (27 loc) · 1.04 KB
/
bench.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(in-package :fast-mpsc-queue)
(defmacro benchmark (make-queue enqueue dequeue)
`(let ((q (,make-queue)))
(time
(progn
(map nil #'bt:join-thread
(cons
(bt:make-thread
(lambda ()
(let ((count 0))
(loop for x = (,dequeue q)
when x do (incf count)
while (< count 8000000))))
:name "consumer")
(mapcar (lambda (x)
(bt:make-thread
(lambda ()
(dotimes (n 1000000)
(,enqueue :foo q)))
:name x))
(mapcar (lambda (n) (format nil "producer-~a" n))
(loop :for n :from 1 :to 8 :collect n)))))))))
(defun benchmark-fast ()
(benchmark make-queue enqueue dequeue))
(require :sb-concurrency)
(defun benchmark-sb-concurrency ()
(benchmark sb-concurrency:make-queue sb-concurrency:enqueue sb-concurrency:dequeue))