On Tue, Feb 15, 2011 at 2:59 AM, Ken Wesson <[email protected]> did NOT write:
> (defn diagonal-sum-4 [n-max]
> (let [cores (.availableProcessors (Runtime/getRuntime))
> step (* 2 cores)]
> (inc
> (reduce +
> (map get
> (doall
> (map #(future (diagonal-sum-4a n-max % step))
> (take cores
> (iterate #(+ 2 %) 0)))))))))
>
> user=> (time (diagonal-sum-4 1001))
> "Elapsed time: 0.21268 msecs"
> 669171001
>
> About a 4x /slowdown/ on my (dual-core) machine.
That's odd. The actual code I wrote is:
(defn diagonal-sum-4 [n-max]
(let [cores (.availableProcessors (Runtime/getRuntime))
step (* 2 cores)]
(inc
(reduce +
(map deref
(doall
(map #(future (diagonal-sum-4a n-max % step))
(take cores
(iterate #(+ 2 %) 0)))))))))
and it's about a 5x slowdown. I don't know how that post got altered
before it went out and after I wrote it. Sorry.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en