performance measurements

Each table row shows performance measurements for this Lisp SBCL program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
500,0004.453.26409,016618  15% 41% 45% 10%
5,000,00041.8230.12415,148618  9% 45% 46% 10%
50,000,000411.02318.53398,796618  25% 25% 26% 25%

Read the ↓ make, command line, and program output logs to see how this program was run.

Read thread-ring benchmark to see what this program should do.


This is SBCL 1.2.10, an implementation of ANSI Common Lisp.

 thread-ring Lisp SBCL program source code

;;; The Computer Language Benchmarks Game
;;; contributed by Witali Kusnezow 2008-12-02

(defparameter *mutex* (sb-thread:make-mutex :name "lock"))

(defconstant  +threads+ 503)
(defparameter *counter* 0)
(defparameter *current* 0)
(defparameter *main-queue* (sb-thread:make-waitqueue))
(defparameter *queues*
  (make-array +threads+
              (loop for i of-type fixnum below +threads+
                 collect (sb-thread:make-waitqueue))))

(declaim (type fixnum *counter* *current*))

(defun thread-body ()
  (sb-thread:with-mutex (*mutex* :wait-p t)
    (let ((number *current*)
          (next (incf *current*)))
      (declare (fixnum number next))
      (if (= next +threads+) (setq next 0))
         with (curr_queue next_queue) =
           (list (svref *queues* number) (svref *queues* next))
         do (sb-thread:condition-wait curr_queue *mutex*)
         until (zerop *counter*)
         do (decf *counter*)  (sb-thread:condition-notify next_queue)
         finally (format t "~d~%" (1+ number))
           (sb-thread:condition-notify *main-queue*)))))

(defun start (n)
  (declare (type fixnum n))
  (setq *counter* n *current* 0)
  (let ((threads
            for i of-type fixnum below +threads+
            collect (sb-thread:make-thread #'thread-body))))
    (sb-thread:condition-notify (svref *queues* 0))
    (sb-thread:with-mutex (*mutex* :wait-p t)
      (sb-thread:condition-wait *main-queue* *mutex*))
    (dolist (i threads)
      (handler-case (sb-thread:terminate-thread i)
        (sb-thread:interrupt-thread-error () nil)))))

(defun main ()
  (let ((n (parse-integer (or (car (last #+sbcl sb-ext:*posix-argv*
                                         #+cmu  extensions:*command-line-strings*
                                         #+gcl  si::*command-args*)) "1"))))
    (start n)))

 make, command-line, and program output logs

Thu, 02 Apr 2015 19:38:35 GMT

cp: ‘threadring.sbcl’ and ‘./threadring.sbcl’ are the same file
SBCL built with: /usr/local/bin/sbcl --userinit /dev/null --batch --eval '(load "threadring.sbcl_compile")'
### START threadring.sbcl_compile
(handler-bind ((sb-ext:defconstant-uneql      (lambda (c) (abort c))))      (load (compile-file "threadring.sbcl" ))) (save-lisp-and-die "sbcl.core" :purify t)
### END threadring.sbcl_compile

; compiling file "/home/dunham/benchmarksgame/bench/threadring/threadring.sbcl" (written 23 JAN 2013 08:21:30 PM):
; compiling (DEFPARAMETER *MUTEX* ...)
; compiling (DEFCONSTANT +THREADS+ ...)
; compiling (DEFPARAMETER *COUNTER* ...)
; compiling (DEFPARAMETER *CURRENT* ...)
; compiling (DEFPARAMETER *MAIN-QUEUE* ...)
; compiling (DEFPARAMETER *QUEUES* ...)
; compiling (DECLAIM (TYPE FIXNUM ...))
; compiling (DEFUN THREAD-BODY ...)
; compiling (DEFUN START ...)
; compiling (DEFUN MAIN ...)

; /home/dunham/benchmarksgame_quadcore/threadring/tmp/threadring.fasl written
; compilation finished in 0:00:00.021
[undoing binding stack and other enclosing state... done]
[saving current Lisp image into sbcl.core:
writing 5824 bytes from the read-only space at 0x20000000
writing 3168 bytes from the static space at 0x20100000
writing 47120384 bytes from the dynamic space at 0x1000000000
### START threadring.sbcl_run
(main) (quit)
### END threadring.sbcl_run

0.40s to complete and log all make actions

/usr/local/bin/sbcl  --noinform --core sbcl.core --userinit /dev/null --load threadring.sbcl_run 50000000


Revised BSD license

  Home   Conclusions   License   Play