handling of cl-loop, setf, elt, or cl-random.
;; First some Emacs, with times on my $100 Chromebook.
(setq n 6)
(defun make-random-array (n)
(let ((a (make-vector n 0)))
(cl-loop for i below n do
(setf (elt a i) (cl-random 1000000)))
a))
(byte-compile 'make-random-array)
(benchmark '(setq foo (make-random-array (expt 10 n))) 1) -- 2.3 seconds
(benchmark '(sort foo '<) 1) -- 1 second
;; Second some Common Lisp, with times for SBCL on my $100 Chromebook.
(defparameter n 6)
(defun make-random-array (n)
(declare (fixnum n))
(let ((a (make-array n)))
(declare (type array a))
(loop for i fixnum below n do
(setf (aref a i) (random most-positive-fixnum)))
a))
(time (defparameter foo (make-random-array (expt 10 n)))) -- .041 seconds
(time (progn (stable-sort foo '<) nil)) -- .45 seconds
Thanks so much for Emacs, which is so great that I cannot put it