Throwing in my 2 cents: (def chunk-size 2000)
(defn sum-tree-part [nums start length] (reduce #(+ %1 (nth nums (+ start %2))) 0 (range length))) (defn sum-partition[nums] (reduce + (pmap #(sum-tree-part nums % chunk-size) (range 0 (count nums) chunk-size)))) ; Save the vec and reuse it. Seems to take longer to create the vec than sum it. (def vec-range (vec (range 1000000))) (println "sum-partition: " (sum-partition vec-range)) (dotimes [_ 5] (time (sum-partition vec-range))) (println "sum-seq: " (sum_seq vec-range)) (dotimes [_ 5] (time (sum_seq vec-range))) (println "sum-tree2: " (sum_tree2 vec-range)) (dotimes [_ 5] (time (sum_tree2 vec-range))) Results: sum-partition: 499999500000 "Elapsed time: 543.951 msecs" "Elapsed time: 521.138 msecs" "Elapsed time: 512.409 msecs" "Elapsed time: 540.504 msecs" "Elapsed time: 512.003 msecs" sum-seq: 499999500000 "Elapsed time: 687.038 msecs" "Elapsed time: 689.839 msecs" "Elapsed time: 690.173 msecs" "Elapsed time: 690.715 msecs" "Elapsed time: 690.543 msecs" sum-tree2: 499999500000 "Elapsed time: 809.912 msecs" "Elapsed time: 829.039 msecs" "Elapsed time: 823.197 msecs" "Elapsed time: 820.383 msecs" "Elapsed time: 821.239 msecs" I have a 5 year old dual core computer. It would be interesting to see if someone with more cores has a greater improvement over sum-seq. -Matt Courtney -- 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 Note that posts from new members are moderated - please be patient with your first post. 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.