Code: Select all
(in-package :cl-user)
(defvar *big-list*)
(defun init-big-list (length)
(setf *big-list*
(loop
for i from 0 below length
collect (cons (random 1000000) 'x)))
nil)
(defun sort1 ()
(setf *big-list* (sort *big-list* #'< :key #'car))
nil)
(defun sort2 ()
(setf *big-list* (sort *big-list* #'(lambda (x y) (< (car x) (car y)))))
nil)
Code: Select all
This is SBCL 1.0.22, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (load "temp.lisp")
T
* (init-big-list 100000)
NIL
* (time (sort1))
Evaluation took:
0.255 seconds of real time
0.247963 seconds of total run time (0.247963 user, 0.000000 system)
97.25% CPU
465,859,427 processor cycles
0 bytes consed
NIL
* (init-big-list 100000)
NIL
* (time (sort2))
Evaluation took:
0.230 seconds of real time
0.219966 seconds of total run time (0.214967 user, 0.004999 system)
95.65% CPU
420,188,509 processor cycles
0 bytes consed
NIL
*