[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dolist inefficiency



In compiled code dolist is almost as efficient as loop, it is a little
bit slower because it uses endp instead of null as the test for the
end of the list.  I don't know why the interpreted version of dolist
is so slow related to loop.

Andreas Girgensohn
andreasg@boulder.colorado.edu

(defun time-loop (foo)
  (time (dotimes (i 1000)
	  (loop for x in foo do x))))

(defun time-dolist (foo)
  (time (dotimes (i 1000)
	  (dolist (x foo) x))))

> (time-loop (make-list 100))
Evaluation of (DOTIMES (I 1000)
                (LOOP FOR X IN FOO DO X)) took 0.520531 seconds of elapsed time including:
  0.008 seconds processing sequence breaks,
  0.001 seconds in the storage system (including 0.000 seconds waiting for pages):
    0.001 seconds processing 2 page faults including 0 fetches,
    0.000 seconds in creating and destroying pages, and
    0.000 seconds in miscellaneous storage system tasks.

> (time-dolist (make-list 100))
Evaluation of (DOTIMES (I 1000)
                (DOLIST #
                  X)) took 0.536804 seconds of elapsed time including:
  0.007 seconds processing sequence breaks,
  0.000 seconds in the storage system (including 0.000 seconds waiting for pages):
    0.000 seconds processing 0 page faults including 0 fetches,
    0.000 seconds in creating and destroying pages, and
    0.000 seconds in miscellaneous storage system tasks.