yes, I started out trying the following example from Practical Clojure: (defn make-heavy [f] (fn [& args] (Thread/sleep 1000) (apply f args)))
user=> (time (+ 5 5)) "Elapsed time: 0.06403 msecs" 10 user=> (time ((make-heavy +) 5 5)) "Elapsed time: 1000.622706 msecs" 10 user=> (time (doall (map (make-heavy inc) [1 2 3 4 5]))) "Elapsed time: 5003.314909 msecs" (2 3 4 5 6) user=> (time (doall (pmap (make-heavy inc) [1 2 3 4 5]))) "Elapsed time: 1000.720951 msecs" (2 3 4 5 6) in this case, pmap is faster. On Nov 7, 3:25 am, André Thieme <splendidl...@googlemail.com> wrote: > Am 06.11.2010 12:57, schrieb philip schwarz: > > > > > > > > > > > Hi all, > > > be gentle please: I have only just started using clojure. > > > I run the following on an Intel Core 2 Duo CPU (starting clojure with > > "java -Xms1000m -Xmx1000m -jar clojure.jar"): > > > user=> (time (nth (doall (map inc (range 10000000))) 9999999)) > > "Elapsed time: 5944.068355 msecs" > > 10000000 > > > user=> (time (nth (doall (pmap inc (range 10000000))) 9999999)) > > "Elapsed time: 108837.451146 msecs" > > 10000000 > > > I was expecting pmap to take less time then map, instead it took much > > much longer. > > > Any thoughts? > > 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. -- 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