On Tue, Jan 13, 2009 at 2:18 AM, Timothy Pratley <timothyprat...@gmail.com> wrote: > > BTW Rich, > > The documentation http://clojure.org/data_structures hints that > accessors are faster than regular map lookups and provides the > following example: > (reduce (fn [n y] (+ n (:fred y))) 0 x) > -> 4999950000 > (reduce (fn [n y] (+ n (fred y))) 0 x) > -> 4999950000 > > However I think it would be clearer if you explicitly showed the speed > improvement: > user=> (time (reduce (fn [n y] (+ n (:fred y))) 0 x)) > "Elapsed time: 100.838989 msecs" > 4999950000 > user=> (time (reduce (fn [n y] (+ n (fred y))) 0 x)) > "Elapsed time: 48.82307 msecs" > 4999950000
With repeated runs, and my cpu frequency set to not change, I get very little speed improvement. I increased the size of the example range times 10 for these runs: user=> (time (reduce (fn [n y] (+ n (:fred y))) 0 x)) "Elapsed time: 112.961087 msecs" 499999500000 user=> (time (reduce (fn [n y] (+ n (fred y))) 0 x)) "Elapsed time: 102.127459 msecs" 499999500000 --Chouser --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---