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,0005.644.07863,968571  47% 23% 3% 50%
5,000,00060.4640.20974,276571  29% 38% 35% 28%
50,000,000539.18395.661,088,856571  31% 28% 27% 30%

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 #2 program source code

;;; The Computer Language Benchmarks Game
;;; contributed by Witali Kusnezow 2008-12-19
;;;     using semaphore synchronization

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

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

(defmacro wait   (semaphore)
  `(sb-thread:wait-on-semaphore ,semaphore))
(defmacro wake (semaphore)
  `(sb-thread:signal-semaphore  ,semaphore))
(defmacro kill   (thread)
  `(handler-case (sb-thread:terminate-thread ,thread)
     (sb-thread:interrupt-thread-error () nil)))

(defun thread-body ()
  (let* ((curr (svref *semaphores* *current*))
         (next (svref *semaphores* (if (= (incf *current*) +threads+) 0 *current*)))
         (number *current*))
    (loop do (wait curr)
       until (zerop (decf *counter*))
       do (wake next)
       finally (format t "~d~%" number) (wake *semaphore*))))

(defun start (n)
  (declare (type fixnum n))
  (setq *counter* (1+ n) *current* 0)
  (loop for i of-type fixnum below +threads+
     collect (sb-thread:make-thread #'thread-body) into threads
       (wake (svref *semaphores* 0))
       (wait *semaphore*)
       (dolist (i threads) (kill i))))

(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

Wed, 01 Apr 2015 23:33:09 GMT

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

; compiling file "/home/dunham/benchmarksgame/bench/threadring/threadring.sbcl-2.sbcl" (written 24 JAN 2013 02:01:16 PM):
; compiling (DEFCONSTANT +THREADS+ ...)
; compiling (DEFPARAMETER *COUNTER* ...)
; compiling (DEFPARAMETER *CURRENT* ...)
; compiling (DEFPARAMETER *SEMAPHORE* ...)
; compiling (DECLAIM (TYPE FIXNUM ...))
; compiling (DEFMACRO WAIT ...)
; compiling (DEFMACRO WAKE ...)
; compiling (DEFMACRO KILL ...)
; compiling (DEFUN THREAD-BODY ...)
; compiling (DEFUN START ...)
; compiling (DEFUN MAIN ...)

; /home/dunham/benchmarksgame_quadcore/threadring/tmp/threadring.sbcl-2.fasl written
; compilation finished in 0:00:00.024
[undoing binding stack and other enclosing state... done]
[saving current Lisp image into sbcl.core:
writing 3496 bytes from the read-only space at 0x1000000
writing 2272 bytes from the static space at 0x1100000
writing 31035392 bytes from the dynamic space at 0x9000000
### START threadring.sbcl-2.sbcl_run
(main) (quit)
### END threadring.sbcl-2.sbcl_run

0.71s to complete and log all make actions

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


Revised BSD license

  Home   Conclusions   License   Play