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
100.420.4228,072674  0% 2% 2% 100%
114.194.2030,116674  0% 1% 1% 100%
1258.1858.1932,160674  1% 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.

 notes

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

 fannkuch-redux Lisp SBCL #5 program source code

;; The Computer Language Benchmarks Game
;; http://benchmarksgame.alioth.debian.org/
;; 
;; Contributed by Karel Belohlavek
;; 
;; Single core implementation.
;; Inspired by the Erlang one by Alkis Gotovos and Maria Christakis.

(eval-when (:execute) (proclaim '(optimize (speed))))

(defun fannkuch (n)
   (labels
    ((mkperm (n)
     (let*
      ((params (loop for i from 1 to n collect (gensym)))
       (flip-branches
         (loop
          for j from 2 to n
          collect
            `((,j)
              ,(append '(flip (the fixnum (1+ acc)))
                       (reverse (subseq params 0 j))
                       (subseq params j)))))
       (nextperm-branches
         (loop
          for j from 0 below n
          for rparams = (append (subseq params 1 (1+ j))
                                (list (car params))
                                (subseq params (1+ j)))
          collect
            `((,j)
              (if (< (aref c i) i) 
               (progn
                (incf (aref c i))
                (let ((nflips (the fixnum (flip 0 ,@rparams))))
                  (declare (type fixnum nflips))
		  (cond (even (incf csum nflips)
		              (setf even nil))
		        (t (decf csum nflips)
			   (setf even t)))
                  (when (> nflips max-flips)
                   (setf max-flips nflips)))
                (perm 1 ,@rparams))
               (progn
                (setf (aref c i) 0)
                (perm (+ i 1) ,@rparams)))))))
      `(lambda ()
	(let ((csum 0)
	      (max-flips 0)
	      (even nil)
	      (c (make-array ,n :initial-element 0 :element-type 'fixnum)))
	  (declare (type fixnum csum max-flips)
	           (type boolean even)
	           (type (simple-array fixnum (,n)) c))
	  (labels
	   ((flip (acc ,@params)
             (declare (type fixnum acc ,@params))
             (ecase ,(car params) ((1) acc) ,@flip-branches))
            (perm (i ,@params)
	     (declare (type fixnum i ,@params))
	     (ecase i
	       (,n (format t "~s~%Pfannkuchen(~s) = ~s~%" csum ,n max-flips))
	       ,@nextperm-branches)))
	   (apply #'perm
	    1
	    (loop for j of-type fixnum from 1 to ,n collect j))))))))
    (funcall (compile nil (mkperm n)))))

(defun main ()  
  (let* ((args (cdr sb-ext:*posix-argv*))
         (n (parse-integer (car args))))
    (fannkuch n)))

 make, command-line, and program output logs

Tue, 25 Nov 2014 06:39:47 GMT

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

; compiling file "/home/dunham/benchmarksgame/bench/fannkuchredux/fannkuchredux.sbcl-5.sbcl" (written 03 APR 2014 09:47:05 AM):
; compiling (DEFUN FANNKUCH ...)
; compiling (DEFUN MAIN ...)

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

0.40s to complete and log all make actions

COMMAND LINE:
/usr/local/bin/sbcl  --noinform --core sbcl.core --userinit /dev/null --load fannkuchredux.sbcl-5.sbcl_run 12

PROGRAM OUTPUT:
3968050
Pfannkuchen(12) = 65

Revised BSD license

  Home   Conclusions   License   Play