fixed it
(defn t [m]
(let [r (java.util.Random.)]
(dotimes [i m] (. r nextDouble)))
(Thread/sleep 1000))
(defn testmap [f n m]
(time (doall (f t (repeat n m)
user=> (testmap map 8 200)
"Elapsed time: 8869.942784 msecs"
(nil nil nil nil nil nil nil nil)
user=> (testmap pmap 8 20
Thanks. I looked at Java doc for random which says
"This method is properly synchronized to allow correct use by more
than one thread. However, if many threads need to generate
pseudorandom numbers at a great rate, it may reduce contention for
each thread to have its own pseudorandom-number generat
On Aug 27, 2011, at 10:41 PM, Andy Fingerhut wrote:
> I suspect that (rand), which calls java.lang.Math.random(), is a synchronized
> method, meaning that if you try to call it from many parallel threads, even
> those on physically separate cores, will execute one at a time. Things could
> ev
I suspect that (rand), which calls java.lang.Math.random(), is a
synchronized method, meaning that if you try to call it from many parallel
threads, even those on physically separate cores, will execute one at a
time. Things could even take more time if you try to execute them in
parallel than seq
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