> Althrough I am new to Clojure, I like it a lot. Because it is
> advertised as native JVM language, I expected it to demostrate decent
> performance in simple numeric tests, so I decided to compare it to
> Python.
>
> Clojure rev. 1173:
> user=> (defn fac [#^Integer n] (reduce * (range 1 (+ 1 n))))
> #'user/fac
> user=> (time (reduce + (map fac (range 1000))))
> "Elapsed time: 944.798019 msecs"
Timing on the JVM is notoriously difficult. Since good performance
depends on the JIT compiler, you can't expect anything to be fast the
first time you run it. So, define a function that runs your benchmark
and run it several times. But even then, microbenchmarks are not the
JVM's strongest point.
Konrad.
BigInteger have problems, but so does that benchmark:
No warm-up.
Includes startup time.
Using client VM.
And probably a number of less obvious things that commonly haunt Java
micro-benchmarks.
On the other hand, we have reason to hope that the big-math story will
improve significantly in JDK 7:
http://markmail.org/message/7conncsespvrlazn
I would be interested to see a Clojure port of my ray tracer benchmark:
http://www.ffconsultancy.com/languages/ray_tracer/
--
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e