Path: utzoo!attcan!uunet!dalsqnt!pollux!ti-csl!pf@csc.ti.com From: pf@csc.ti.com (Paul Fuqua) Newsgroups: comp.lang.lisp Subject: Re: Summing a list Message-ID: <62445@ti-csl.CSNET> Date: 1 Nov 88 03:57:02 GMT References: <29718@think.UUCP> Sender: news@ti-csl.CSNET Organization: TI Computer Science Center, Dallas Lines: 41 Date: Wednesday, October 26, 1988 11:23am (CDT) From: barmar at think.COM (Barry Margolin) Subject: Re: Summing a list Newsgroups: comp.lang.lisp I decided to time all the various methods that have been discussed. I tried them on a Symbolics 3640 running Genera 7.2 and a Sun 3/280 running Lucid CL 2.0.3. I used the default OPTIMIZE parameters. To add another implementation to the pot, I ran roughly the same code on a TI Explorer 2 running release 4.1+, also with the default optimisations. I included Mark Johnson's tail-recursive versions, and both helper-function and LABELS versions of the original recursive code. The fastest were DO-LOOP, APPLY-+, and TRECURSIVE (tail-recursion using LABELS). The latter is up there because the compiler managed to open-code the recursive calls into a loop, so all three are running essentially the same code. Next in line are RECURSIVE1 and TRECURSIVE1 (two helper-function recursive versions), and REDUCE-+, all about 7 times as long. No open-coding here, it's all function-calling speed. The slowpoke of the bunch was RECURSIVE (Barry Margolin's original code), at about 13 times as long, because it's forming and discarding lexical closures on each function call (all stack-consing, though). It was this surprising result that led me to examine the code. [I was unable to run EVAL-+, because the evaluator spread the whole list onto the stack and exceeded the 256-word limit on stack frames. (APPLY-+ doesn't do that, because it's applying a function that takes a &REST argument.) On a shorter list, it was about 6 times as long as DO-LOOP.] pf Paul Fuqua Texas Instruments Computer Science Center, Dallas, Texas CSNet: pf@csc.ti.com (ARPA too, sometimes) UUCP: {smu, texsun, cs.utexas.edu, im4u, rice}!ti-csl!pf