Johann Kraus <johann.kr...@gmail.com> writes: > Doing this with doubles:
> leads to: > (time (maptest 8)) : 68044.060324 msecs > (time (pmaptest 8)) : 35051.174503 msecs > i.e. a speedup of ~2. > > However, the CPU usage indicated by "top" is ~690%. What does the CPU > do? My guess would be you're seeing the overhead for pmap since the (inc 0.1) computation is so cheap. From the docs for pmap: "Only useful for computationally intensive functions where the time of f dominates the coordination overhead." Maybe try this with something more expensive to compute? Also, making the result a function of the parameter can't hurt since there's a chance the JVM may optimize away the inc of a constant as it stands. On my 2.4 GHz Core 2 Duo with JVM 1.6.0_13, here's what your pmaptest with doubles looked like: user=> (time (maptest 1)) "Elapsed time: 11979.023 msecs" user=> (time (maptest 2)) "Elapsed time: 23930.877 msecs" (nil nil) user=> (time (pmaptest 1)) "Elapsed time: 11912.518 msecs" (nil) user=> (time (pmaptest 2)) "Elapsed time: 23917.375 msecs" I.e., no speedup at all! The communication and coordination overhead easily dwarfs the actual computation. After replacing the (inc 0.1) with (+ x 0.1 x) and reduced the number of iterations by a factor of 10: user=> (defn pmaptest [cores] (doall (pmap (fn [x] (dotimes [_ 100000000] (+ x 0.1 x))) (range cores)))) user=> (time (maptest 1)) "Elapsed time: 16173.675 msecs" (nil) user=> (time (maptest 2)) "Elapsed time: 32351.821 msecs" user=> (time (pmaptest 1)) "Elapsed time: 16399.574 msecs" (nil) user=> (time (pmaptest 2)) "Elapsed time: 17574.663 msecs" Now there's a not quite linear speedup. This ratio should get closer to linear as the overhead for f gets higher. -- Sudish Joseph --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---