On Dec 8, 2012, at 1:28 PM, Paul deGrandis wrote:
> My experiences in the past are similar to the numbers that Jim is reporting.
>
> I have recently been centering most of my crunching code around reducers.
> Is it possible for you to cook up a small representative test using
> reducers+fork/join (and potentially primitives in the intermediate steps)?
>
> Perhaps it can shed some light on contention or chunking issues (and
> eliminate some of the allocation concerns).
Just tried, my first foray into reducers, but I must not be understanding
something correctly:
(time (r/map burn (doall (range 4))))
returns in less than a second on my macbook pro, whereas
(time (doall (map burn (range 4))))
takes nearly a minute.
This feels like unforced laziness (although it's not quite that fast), but
clojure.core.reducers/map involves no laziness, right?
I think my burn function (reproduced below for convenience) forces all of the
laziness in there...
So what am I doing wrong?
BTW the runs described in this message use Clojure 1.5.0-alpha3 -- the ones in
previous messages in this thread used Clojure 1.3.0.
-Lee
(defn burn
([] (loop [i 0
value '()]
(if (>= i 10000)
(count (last (take 10000 (iterate reverse value))))
(recur (inc i)
(cons
(* (int i)
(+ (float i)
(- (int i)
(/ (float i)
(inc (int i))))))
value)))))
([_] (burn)))
--
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