Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!cwjcc!hal!nic.MR.NET!shamash!nis!ems!srcsip!orion!rogers From: rogers@orion.SRC.Honeywell.COM (Brynn Rogers) Newsgroups: comp.lang.lisp Subject: Followup to The BEST way to sum Message-ID: <10848@srcsip.UUCP> Date: 26 Oct 88 15:03:33 GMT Sender: news@src.honeywell.COM Reply-To: rogers@orion.UUCP (Brynn Rogers) Organization: Honeywell Systems & Research Center, Camden, MN Lines: 29 References: Thanks to everyone who responded. I posted this problem not because of any great need for speed, but to learn the best way to program. (setq nn '(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)) (everything was wrapped in (dotimes (x 20000) (testalgorithm)) and compiled. results with TIME function: algorithm time --------- ---- (apply #'+ nn) 4.18 (dolist ...) 4.22 recursive sum 8.35 (eval (cons '+ nn) 8.40 (reduce #'+ nn) 16.75 The dolist and the apply came in first with virtually the same time The recursive sum function surprised me (but not some who responded) by being so fast. I don't know why reduce was slow. I am going to use the apply function because it is the most elegant. I realize that how good the compiler is the major determineing factor here. Thanks for responding! Brynn Rogers rogers@src.honeywell.com P.S. we have clocked GC COMMON LISP on our 386/20 to be about 1/4 the speed of a Symbolics 3640 machine (at 1/40 the price approx.) (this was a Very rough comparison. Someday I'll clock it against the SUNs)