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
5000.210.21264625  9% 0% 0% 100%
3,0007.017.0110,176625  1% 0% 100% 1%
5,50023.3923.4010,176625  0% 0% 100% 0%

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

Read spectral-norm benchmark to see what this program should do.


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

 spectral-norm Lisp SBCL program source code

;;   The Computer Language Benchmarks Game
;;    Adapted from the C (gcc) code by Sebastien Loisel
;;    Contributed by Christopher Neufeld
;;    Modified by Juho Snellman 2005-10-26
;;      * Use SIMPLE-ARRAY instead of ARRAY in declarations
;;      * Use TRUNCATE instead of / for fixnum division
;;      * Rearrange EVAL-A to make it more readable and a bit faster

;; Note that sbcl is at least 10 times faster than either clisp or gcl
;; on this program, running with an argument of 500.  It would be nice
;; to know why the others are so slow.

(defun eval-AtA-times-u (n u)
  (eval-At-times-u n (eval-A-times-u n u)))

;; This is our most expensive function.  Optimized with the knowledge
;; that 'n' will never be "huge".  This will break if 'n' exceeds
;; approximately half of the square root of the largest fixnum
;; supported by the implementation.  On sbcl 0.9.3,
;; 'most-positive-fixnum' is 536870911, and we can support values of
;; 'n' above 11000.
(declaim (inline eval-A))
(defun eval-A (i j)
  (declare (type fixnum i j))
  (let* ((n (+ i j))
         (n+1 (1+ n)))
    (declare (fixnum n n+1))
    (/ (float (+ (truncate (the fixnum (* n n+1)) 2) i 1) 0d0))))

(defun eval-A-times-u (n u)
  (declare (type fixnum n)
           (type (simple-array double-float) u))
  (let ((retval (make-array n :element-type 'double-float :initial-element 0.0d0)))
    (dotimes (i n)
      (dotimes (j n)
        (incf (aref retval i) (* (eval-A i j) (aref u j)))))

(defun eval-At-times-u (n u)
  (declare (type fixnum n)
           (type (simple-array double-float) u))
  (let ((retval (make-array n :element-type 'double-float :initial-element 0.0d0)))
    (dotimes (i n)
      (dotimes (j n)
        (incf (aref retval i) (* (eval-A j i) (aref u j)))))

(defun main (&optional n-supplied)
  (let ((n (or n-supplied
               (parse-integer (or (car (last #+sbcl sb-ext:*posix-argv*
                                             #+clisp ext:*args*
                                             #+cmu extensions:*command-line-strings*
                                             #+gcl  si::*command-args*))
    (or (typep (* (- (* 2 n) 1) (- (* 2 n) 2)) 'fixnum)
        (error "The supplied value of 'n' breaks the optimizations in EVAL-A"))
    (let ((u (make-array n :element-type 'double-float :initial-element 1.0d0))
          (v (make-array n :element-type 'double-float)))
      (declare (type (simple-array double-float) U V))
      (dotimes (i 10)
        (setf v (eval-AtA-times-u n u))
        (setf u (eval-AtA-times-u n v)))
      (let ((vBv 0.0d0)
            (vv 0.0d0))
        (dotimes (i n)
          (incf vBv (* (aref u i) (aref v i)))
          (incf vv (* (aref v i) (aref v i))))
        (format t "~11,9F~%" (sqrt (the (double-float 0d0) (/ vBv vv))))))))

;; #+sbcl (progn
;;          (sb-profile:profile eval-AtA-times-u)
;;          (sb-profile:profile eval-A)
;;          (sb-profile:profile eval-A-times-u)
;;          (sb-profile:profile eval-At-times-u)
;;          (sb-profile:profile main))

 make, command-line, and program output logs

Wed, 01 Apr 2015 23:29:22 GMT

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

; compiling file "/home/dunham/benchmarksgame/bench/spectralnorm/spectralnorm.sbcl" (written 24 JAN 2013 02:01:16 PM):
; compiling (DEFUN EVAL-ATA-TIMES-U ...)
; compiling (DECLAIM (INLINE EVAL-A))
; compiling (DEFUN EVAL-A ...)
; compiling (DEFUN EVAL-A-TIMES-U ...)
; compiling (DEFUN EVAL-AT-TIMES-U ...)
; compiling (DEFUN MAIN ...)

; /home/dunham/benchmarksgame_quadcore/spectralnorm/tmp/spectralnorm.fasl written
; compilation finished in 0:00:00.048
[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 30986240 bytes from the dynamic space at 0x9000000
### START spectralnorm.sbcl_run
(main) (quit)
### END spectralnorm.sbcl_run

0.72s to complete and log all make actions

/usr/local/bin/sbcl  --noinform --core sbcl.core --userinit /dev/null --load spectralnorm.sbcl_run 5500


Revised BSD license

  Home   Conclusions   License   Play