Am 07.11.2010 04:29, schrieb Ken Wesson:
On Sat, Nov 6, 2010 at 11:25 PM, André Thieme
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)
--
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