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
250,0003.843.8589,112847  1% 1% 1% 100%
2,500,000Timed Out  847   

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

Read k-nucleotide benchmark to see what this program should do.


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

 k-nucleotide Lisp SBCL program source code

;;   The Computer Language Benchmarks Game
;;   contributed by James McIlree
;;   Modified by Juho Snellman 2005-11-19
;;     * About 50% speedup on both SBCL and CMUCL
;;       lower memory use on Unicode SBCL
;;     * Declare the type of SEQUENCE in ACCUMULATE-FREQUENCIES

(defun read-data (stream)
  (let ((data (make-array 0 :element-type 'base-char :adjustable t :fill-pointer 0)))
    (do ((line (read-line stream nil 'eof) (read-line stream nil 'eof)))
        ((or (eq line 'eof) (string= ">THREE" line :start2 0 :end2 6))))
    (do ((line (read-line stream nil 'eof) (read-line stream nil 'eof)))
        ((or (eq line 'eof) (char= (schar line 0) #\>)))
      (if (not (char= (schar line 0) #\;))
          (dotimes (char-index (length line))
            (vector-push-extend (char-upcase (the base-char (schar line char-index))) data))))
    (coerce data 'simple-base-string)))

(defun accumulate-frequencies (hashmap sequence offset fragment-length)
  (declare (type (integer 0 18) fragment-length)
           (fixnum offset)
           (type (simple-base-string) sequence))
  (let ((last-sequence-index (- (length sequence) fragment-length)))
    (do ((start offset (+ start fragment-length)))
        ((> start last-sequence-index))
      (let ((fragment (subseq sequence start (+ start fragment-length))))
        (setf (gethash fragment hashmap) (1+ (the (integer 0 999999) (gethash fragment hashmap 0))))))))

(defun calculate-frequencies (sequence fragment-length)
  (declare (type (integer 0 18) fragment-length))
  (let ((hashmap (make-hash-table :test #'equal)))
    (dotimes (offset fragment-length)
      (accumulate-frequencies hashmap sequence offset fragment-length))

(defun write-frequencies (sequence length)
  (let ((sorted-frequencies)
        (sum 0))
    (declare (fixnum sum))
    (maphash #'(lambda (k v)
                 (setf sum (+ sum (the fixnum v)))
                 (setf sorted-frequencies (cons (cons k v) sorted-frequencies))) (calculate-frequencies sequence length))
    (setf sorted-frequencies (sort sorted-frequencies #'(lambda (v1 v2)
                                                          (cond ((> (the (integer 0 999999) (cdr v1)) (the (integer 0 999999) (cdr v2))) t)
                                                                ((< (the (integer 0 999999) (cdr v1)) (the (integer 0 999999) (cdr v2))) nil)
                                                                (t (string< (car v1) (car v2)))))))
    (dolist (entry sorted-frequencies) (format t "~A ~,3F~%" (car entry) (* (/ (the (integer 0 999999) (cdr entry)) sum) 100.0)))

;; Delete this before including in the shootout, test method only.
;;(defun test-main (filename)
;;  (with-open-file (stream filename)
;;    (let ((sequence (read-data stream)))
;;      (declare (type (simple-array * *) sequence))
;;      (dolist (entry '(1 2)) (write-frequencies sequence entry))
;;        (declare (type (simple-array * *) entry))
;;        (format t "~A~C~A~%" (gethash entry (calculate-frequencies sequence (length entry)) 0) #\Tab entry)))))

(defun main ()
  (let ((sequence (read-data *standard-input*)))
    (declare (type (simple-array * *) sequence))
    (dolist (entry '(1 2)) (write-frequencies sequence entry))
      (declare (type (simple-array * *) entry))
      (format t "~A~C~A~%"
              (gethash entry (calculate-frequencies sequence (length entry)) 0)
              #\Tab entry))))

 make, command-line, and program output logs

Sun, 01 Jun 2014 02:46:57 GMT

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

; compiling file "/home/dunham/benchmarksgame/bench/knucleotide/knucleotide.sbcl" (written 23 JAN 2013 08:18:38 PM):
; compiling (DEFUN READ-DATA ...)
; compiling (DEFUN MAIN ...)

; /home/dunham/benchmarksgame_onecore/knucleotide/tmp/knucleotide.fasl written
; compilation finished in 0:00:00.052
[undoing binding stack and other enclosing state... done]
[saving current Lisp image into sbcl.core:
writing 5792 bytes from the read-only space at 0x0x20000000
writing 3120 bytes from the static space at 0x0x20100000
writing 45809664 bytes from the dynamic space at 0x0x1000000000
### START knucleotide.sbcl_run
(main) (quit)
### END knucleotide.sbcl_run

0.44s to complete and log all make actions

/usr/local/bin/sbcl  --noinform --core sbcl.core --userinit /dev/null --load knucleotide.sbcl_run 0 < knucleotide-input2500000.txt

TIMED OUT after 600s


debugger invoked on a TYPE-ERROR in thread
#<THREAD "main thread" RUNNING {1002BB52D3}>:
  The value 1000000 is not of type (MOD 1000000).

Revised BSD license

  Home   Conclusions   License   Play