I came across this post talking about numerical speed in Clojure, so I thought I would try out the equivalent in Common Lisp (Clozure CL) on my Macbook:
CL-USER> (let* ((arr-size 3000000)
(double-arr (make-array arr-size :element-type 'single-float)))
(dotimes (i arr-size)
(setf (aref double-arr i) (random 1.0)))
(time (loop for i from 0 below arr-size
summing (aref double-arr i))))
(LOOP FOR I FROM 0 BELOW ARR-SIZE SUMMING (AREF DOUBLE-ARR I))
took 45,649 microseconds (0.045649 seconds) to run.
During that period, and with 4 available CPU cores,
45,558 microseconds (0.045558 seconds) were spent in user mode
57 microseconds (0.000057 seconds) were spent in system mode
45 milliseconds, not bad.
As a followup to my initial getting started post:
* I later replaced the Clozure App with the command-line version, obtained by
`svn co http://svn.clozure.com/publicsvn/openmcl/release/1.9/darwinx86/ccl`
- The basic slime (running in
comint mode) is a bit too bare-bones, and it’s much better to add
`(setq slime-contribs ‘(slime-fancy))`
Here’s what I did, though perhaps a better order of steps exists:
- Downloaded Emacs for OSX
Downloaded ClozureCL from the Mac App Store.
Ran ClozureCL, then “File -> Load File …”, and selected
quicklisp.lisp downloaded earlier.
(ql:add-to-init-file) to make sure I don’t have to repeat this step again
(ql:quickload :quicklisp-slime-helper). This downloaded SLIME and told me what to add to my
`(load (expand-file-name “~/quicklisp/slime-helper.el”))`
`ln -s /Applications/Clozure CL.app/Contents/MacOS/dx86cl64 ~/bin/ccl`
- Added a reference to this in my
`(setq inferior-lisp-program “~/bin/ccl”)`
- Ran emacs,
M-x slime works !
(or as the prompt says, “Happy hacking!”)