I understand that pmap needs to have big chunks to overcome the
overhead but I don't understand my results

(defn t [m]
  (dotimes [i m] (rand))
  (Thread/sleep 1000))

(defn testmap [f n m]
  (time (doall (f t (repeat n m)))))

user=> (testmap map 8 100)
"Elapsed time: 8108.174484 msecs"
(nil nil nil nil nil nil nil nil)
user=> (testmap pmap 8 100)
"Elapsed time: 1006.797146 msecs"
(nil nil nil nil nil nil nil nil)
user=> (testmap pmap 8 1000000)
"Elapsed time: 3781.967909 msecs"
(nil nil nil nil nil nil nil nil)
user=> (testmap map 8 1000000)
"Elapsed time: 8544.896008 msecs"
(nil nil nil nil nil nil nil nil)
user=> (testmap map 8 10000000)
"Elapsed time: 10663.057874 msecs"
(nil nil nil nil nil nil nil nil)
user=> (testmap pmap 8 10000000)
"Elapsed time: 29525.579612 msecs"
(nil nil nil nil nil nil nil nil)

I'm using an i7 with 8 processors so the Thread alone mostly gives an
8-fold speedup. Calling (rand) more times impacts pmap even though I
map and pmap on a list of size 8 to spawn eight functions each with a
lot of work.

-- 
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

Reply via email to