/mobile Handheld Friendly website
x64 Ubuntu : Intel® Q6600® one core |
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 |
|---|---|---|---|---|---|
| 10 | 0.52 | 0.52 | 4,780 | 513 | 0% 0% 2% 98% |
| 11 | 6.43 | 6.43 | 4,780 | 513 | 0% 0% 1% 100% |
| 12 | 86.70 | 86.72 | 4,780 | 513 | 0% 0% 0% 100% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read fannkuch-redux benchmark to see what this program should do.
This is SBCL 1.1.7, an implementation of ANSI Common Lisp.
;; The Computer Language Benchmarks Game ;; http://benchmarksgame.alioth.debian.org/ ;;; ;;; By Jon Smith ;;; Tranlated from OCaml implementation by ?, who translated it from ;;; the Scala implementation by Otto Bommer. ;;; ;;; This is a single core implementation. ;;; I am sure that this program can be improved upon quite a lot. ;;; Most likely it will involve knowing how sbcl does its optimizations. ;;; As you can see, I simply used fixnums everywhere. There may be a better choice. ;;; ;;; To compile ;;; sbcl --load fannkuch.lisp --eval "(save-lisp-and-die \"fannkuch.core\" :purify t :toplevel (lambda () (main) (quit)))" ;;; To run ;;; sbcl --noinform --core fannkuch.core %A (declaim (optimize (speed 3) (safety 0) (space 1) (debug 0))) (defun fannkuch (n) (declare (type fixnum n)) (let ((csum 0) (fmax 0)) (declare (type fixnum fmax)) (let ((perm (make-array n :element-type 'fixnum)) (copy (make-array n :element-type 'fixnum)) (num 0)) (loop for i from 0 to (- n 1) do (setf (aref perm i) i)) (labels ((do-iter (ht) (declare (type fixnum ht)) (if (= ht 1) (progn (loop for i from 0 to (- n 1) do (setf (aref copy i) (aref perm i))) (let ((c 0)) (declare (type fixnum c)) (let ((z (aref copy 0))) (loop until (= z 0) do (progn (loop for i from 0 to (ash z -1) do (let ((temp (aref copy i)) (k (- z i))) (setf (aref copy i) (aref copy k)) (setf (aref copy k) temp))) (incf c) (setf z (aref copy 0))))) (setf csum (+ csum (if (evenp num) c (- c)))) (when (> c fmax) (setf fmax c))) (incf num)) (loop for i from 1 to ht do (progn (do-iter (- ht 1)) (let ((temp (aref perm 0)) (m (- ht 1))) (loop for i from 1 to m do (setf (aref perm (- i 1)) (aref perm i))) (setf (aref perm m) temp))))))) (do-iter n))) (format t "~s~%Pfannkuchen(~s) = ~s~%" csum n fmax))) (defun main () (let* ((args (cdr sb-ext:*posix-argv*)) (n (parse-integer (car args)))) (fannkuch n)))
Sat, 04 May 2013 00:41:50 GMT MAKE: cp: ‘fannkuchredux.sbcl-2.sbcl’ and ‘./fannkuchredux.sbcl-2.sbcl’ are the same file SBCL built with: /usr/local/bin/sbcl --userinit /dev/null --batch --eval '(load "fannkuchredux.sbcl-2.sbcl_compile")' ### START fannkuchredux.sbcl-2.sbcl_compile (handler-bind ((sb-ext:defconstant-uneql (lambda (c) (abort c)))) (load (compile-file "fannkuchredux.sbcl-2.sbcl" ))) (save-lisp-and-die "sbcl.core" :purify t) ### END fannkuchredux.sbcl-2.sbcl_compile ; compiling file "/home/dunham/benchmarksgame/bench/fannkuchredux/fannkuchredux.sbcl-2.sbcl" (written 23 JAN 2013 08:17:04 PM): ; compiling (DECLAIM (OPTIMIZE # ...)) ; compiling (DEFUN FANNKUCH ...) ; file: /home/dunham/benchmarksgame/bench/fannkuchredux/fannkuchredux.sbcl-2.sbcl ; in: DEFUN FANNKUCH ; (+ CSUM ; (IF (EVENP NUM) ; C ; (- C))) ; ; note: unable to ; optimize ; due to type uncertainty: ; The first argument is a NUMBER, not a FLOAT. ; (EVENP NUM) ; --> NOT IF LOGTEST NOT IF ZEROP = ; ==> ; (LOGAND SB-C::X SB-C::Y) ; ; note: forced to do static-fun Two-arg-and (cost 53) ; unable to do inline fixnum arithmetic (cost 1) because: ; The first argument is a UNSIGNED-BYTE, not a FIXNUM. ; unable to do inline fixnum arithmetic (cost 2) because: ; The first argument is a UNSIGNED-BYTE, not a FIXNUM. ; etc. ; (+ CSUM ; (IF (EVENP NUM) ; C ; (- C))) ; ; note: forced to do GENERIC-+ (cost 10) ; unable to do inline fixnum arithmetic (cost 2) because: ; The first argument is a NUMBER, not a FIXNUM. ; The result is a (VALUES NUMBER &OPTIONAL), not a (VALUES FIXNUM &REST T). ; unable to do inline (signed-byte 64) arithmetic (cost 5) because: ; The first argument is a NUMBER, not a (SIGNED-BYTE 64). ; The result is a (VALUES NUMBER &OPTIONAL), not a (VALUES (SIGNED-BYTE 64) ; &REST T). ; etc. ; (INCF NUM) ; --> LET* ; ==> ; (+ NUM #:G18) ; ; note: forced to do GENERIC-+ (cost 10) ; unable to do inline fixnum arithmetic (cost 1) because: ; The first argument is a UNSIGNED-BYTE, not a FIXNUM. ; The result is a (VALUES (INTEGER 1) &OPTIONAL), not a (VALUES FIXNUM ; &REST T). ; unable to do inline fixnum arithmetic (cost 2) because: ; The first argument is a UNSIGNED-BYTE, not a FIXNUM. ; The result is a (VALUES (INTEGER 1) &OPTIONAL), not a (VALUES FIXNUM ; &REST T). ; etc. ; compiling (DEFUN MAIN ...); ; compilation unit finished ; printed 4 notes ; /home/dunham/benchmarksgame_onecore/fannkuchredux/tmp/fannkuchredux.sbcl-2.fasl written ; compilation finished in 0:00:00.032 [undoing binding stack and other enclosing state... done] [saving current Lisp image into sbcl.core: writing 5952 bytes from the read-only space at 0x0x20000000 writing 4064 bytes from the static space at 0x0x20100000 writing 43352064 bytes from the dynamic space at 0x0x1000000000 done] ### START fannkuchredux.sbcl-2.sbcl_run (main) (quit) ### END fannkuchredux.sbcl-2.sbcl_run 0.38s to complete and log all make actions COMMAND LINE: /usr/local/bin/sbcl --noinform --core sbcl.core --userinit /dev/null --load fannkuchredux.sbcl-2.sbcl_run 12 PROGRAM OUTPUT: 3968050 Pfannkuchen(12) = 65