I haven't tried it, but for parallelisation it's sometimes worth starting
from more "array-oriented" code, e.g.
(defn max-diff [check-until]
(let [val (map #(Math/sqrt %) (range 1 check-until))]
(reduce max (map #(Math/abs (- %1 %2)) (map #(Math/pow % 2) val) (map
#(* % %) val)
On Fr
2014-04-11 3:10 GMT+02:00 Andy Fingerhut :
> Your check-concurrent2 is a much better way to use parallelism in your
> program -- create a few threads, each of which does a lot of work.
>
> I haven't analyzed the values you are computing in detail, but note that
> your program still has lots of int
Your check-concurrent2 is a much better way to use parallelism in your
program -- create a few threads, each of which does a lot of work.
I haven't analyzed the values you are computing in detail, but note that
your program still has lots of inter-thread 'communication' because of the
use of a com
2014-04-10 16:45 GMT+02:00 Andy Fingerhut :
> Forcing small bits of computation to be done in parallel using the tools
> Clojure and the JVM have at hand, e.g. pmap, future, etc., which rely on
> creating JVM Thread objects, tends to slow things down rather than speed
> things up, because the extr
Some would also argue that any parallelism system is going to slow down
code as trivial as this. Never underestimate the power of properly
optimized single threaded code :-).
But yes, futures are the way to go if you want to execute a given
expression on a different thread.
On Thu, Apr 10, 2014
Forcing small bits of computation to be done in parallel using the tools
Clojure and the JVM have at hand, e.g. pmap, future, etc., which rely on
creating JVM Thread objects, tends to slow things down rather than speed
things up, because the extra overhead of creating threads and waiting for
them t
I have the following in my code:
(let [val (Math/sqrt i)
diff (Math/abs (- (Math/pow val 2) (* val val)))]
I expect that calculating the difference is the most expensive part of my
code. I understood that Clojure is very good in parallellisation. How would
I let (Math/pow val 2)