-
Notifications
You must be signed in to change notification settings - Fork 14
/
queues-bench.lisp
57 lines (52 loc) · 1.9 KB
/
queues-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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(eval-when (:compile-toplevel)
(ql:quickload '(:lparallel :jpl-queues :sento)))
(defstruct queue-obj a b c)
(defparameter *sync-unbounded-queue*
(make-instance 'jpl-queues:synchronized-queue
:queue
(make-instance 'jpl-queues:unbounded-fifo-queue)))
(defparameter *sync-bounded-queue*
(make-instance 'jpl-queues:synchronized-queue
:queue
(make-instance 'jpl-queues:bounded-fifo-queue
:capacity 1000000)))
(defun queue-and-dequeue-jpl (queue)
(loop :repeat 1000000
:do
(progn
(jpl-queues:enqueue
(make-queue-obj :a 1 :b 2 :c 3)
queue)
(jpl-queues:dequeue queue))))
(defparameter *sento-unbounded-queue*
(make-instance 'queue:queue-unbounded))
(defparameter *speedy-queue*
(make-instance 'queue:queue-bounded :max-items 2000000))
(defun queue-and-dequeue-sento (queue)
(loop :repeat 1000000
:do
(progn
(queue:pushq
queue
(make-queue-obj :a 1 :b 2 :c 3))
(queue:popq queue))))
(defparameter *cons-queue* (lparallel.cons-queue:make-cons-queue))
(defun queue-and-dequeue-cq (queue)
(loop :repeat 1000000
:do
(progn
(lparallel.cons-queue:push-cons-queue
(make-queue-obj :a 1 :b 2 :c 3)
queue)
(lparallel.cons-queue:pop-cons-queue queue))))
(defun run-tests ()
(format t "jpl-unbounded:~%")
(time (queue-and-dequeue-jpl *sync-unbounded-queue*))
(format t "jpl-bounded:~%")
(time (queue-and-dequeue-jpl *sync-bounded-queue*))
(format t "mabe sento-unbounded queue:~%")
(time (queue-and-dequeue-sento *sento-unbounded-queue*))
(format t "mabe speedy-queue:~%")
(time (queue-and-dequeue-sento *speedy-queue*))
(format t "cons-queue unbounded:~%")
(time (queue-and-dequeue-cq *cons-queue*)))