Note that total CPU time for pmap will always have some extra overhead above the corresponding map - it is recommended to use it when that extra overhead is small compared to the total computation time required.
Andy
Sent from my iPhone
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
Try
(time (count (map (fn [_] (Thread/sleep 1)) (range 1000))))
vs.
(time (count (pmap (fn [_] (Thread/sleep 1)) (range 1000))))
On my system this is 1002 msecs vs. 39 msecs.
Your system has TWENTY-FIVE CORES?!
I wished :-)
I have a dual core CPU.
user> (time (count (pmap (fn [_] (Thread/sleep 3000)) (range 10))))
"Elapsed time: 3001.318114 msecs"
10
user> (time (count (pmap (fn [_] (Thread/sleep 3000)) (range 20))))
"Elapsed time: 3004.243067 msecs"
20
user> (time (count (pmap (fn [_] (Thread/sleep 3000)) (range 30))))
"Elapsed time: 3005.278395 msecs"
30
user> (time (count (pmap (fn [_] (Thread/sleep 3000)) (range 100))))
"Elapsed time: 12002.598445 msecs"
100
I guess this has to do with Thread/sleep suspending the threads back
into the pool, so within just a few msecs. tons of threads were started
only to be suspended, and their wakeup timer fired +/- the same time.
That is my current interpretation, but I would like to hear others.
(Windows Vista, 32 Bit, Java 6 Update 22)