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

Dolist inefficiency



Why is dolist so inefficient? -

> (progn (setf foo (loop for x below 1000 collect x)) nil)

> (time (loop for x in foo do x))
Evaluation of (LOOP FOR X IN FOO DO X) took 0.806763 seconds of elapsed time including:
  0.034 seconds processing sequence breaks,
  0.011 seconds in the storage system (including 0.000 seconds waiting for pages):
    0.011 seconds processing 61 page faults including 0 fetches,
    0.000 seconds in creating and destroying pages, and
    0.000 seconds in miscellaneous storage system tasks.
162 list, 8 structure words consed in WORKING-STORAGE-AREA.

> (time (dolist (x foo) x))
Evaluation of (DOLIST (X FOO)
                  X) took 19.384333 seconds of elapsed time including:
  0.558 seconds processing sequence breaks,
  0.889 seconds in the storage system (including 0.000 seconds waiting for pages):
    0.250 seconds processing 1613 page faults including 0 fetches,
    0.639 seconds in creating and destroying pages, and
    0.000 seconds in miscellaneous storage system tasks.
121,056 list, 16,024 structure words consed in WORKING-STORAGE-AREA.