Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!decwrl!shelby!neon!michaelg From: michaelg@Neon.Stanford.EDU (Michael Greenwald) Newsgroups: comp.lang.lisp Subject: Re: Speed of DOLIST vs. MAP... (was: Mapping is beautiful) Message-ID: <1991Feb21.000741.455@Neon.Stanford.EDU> Date: 21 Feb 91 00:07:41 GMT References: <67@san-jacinto.cs.utexas.edu> Organization: Computer Science Department, Stanford University Lines: 33 gideon@cs.utexas.edu (Timothy Tin-Wai Chan) writes: > Since someone mentioned about mapping, I want to take this >opportunity to ask a question I've always wanted an answer for: > Which CL function runs faster, DOLIST or MAP...? >(I'm doing quite a big CL program that loops extensively and I'd like to > speed up my program. I'm not sure if I should use DOLIST or MAP... > in situations when I can use either.) There is no single answer to this question. If the body of the loop is large compared to the cost of the loop itself, then the relative costs of DOLIST or MAP don't matter. In general, it depends on the implementation. DOLIST is often optimized better (i.e. produces faster code) than MAP because DOLIST is a macro (so it's inlined and in addition to saving the function call (which might not be very expensive, anyway) additional optimizations might be applicable). But, meter your code. There are probably (just a guess, since I have no idea about your application) other places you can speed up your code more significantly than by switching between MAP and DOLIST. >-- >---------------------------------------------------------------------- >"Greater love has no man known, than a man lay his life down for his > friends." (John 15:13) --- . ____ >-- Timothy Chan (timothy@ccwf.cc.utexas.edu) / / / / /