Benchmarks like this are often considered red herrings by language developers. Mostly because they are testing the wrong thing. In this case you are basically testing the performance of big ints in Python to the performance of big ints in Clojure (and Java). Since no one really ever uses big integers in production (at least I've never encountered them in the wild), they tend to be rather poorly optimized.
So the gist of the whole thing is....don't do micro-benchmarks. Timothy On Wed, Dec 31, 2014 at 5:19 PM, shintotomoe <tstei...@atlassian.com> wrote: > My results with hotspot 1.7.0_51, clojure 1.7.0-alpha4 are 13s for python > and 15s for clojure. > > I also tested the python version translated to clojure: > > (defn fib [n] > (loop [n n a 0N b 1N] > (if (zero? n) a (recur (dec n) b (+ a b))))) > > Which was also 15s! I think all the time in the clojure version is > probably spent in the bignum implementation. It seems the lazy-seq does not > add any discernible overhead at all (at least in this microbenchmark). > > user=> (time (rem (nth (lazy-seq-fibo) 1000000) 1000)) > "Elapsed time: 15349.57006 msecs" > 875N > > user=> (time (rem (fib 1000000) 1000)) > "Elapsed time: 15170.386957 msecs" > 875N > > > $ time python fib.py > 875 > > real 0m12.802s > user 0m12.733s > sys 0m0.032s > > $ java -version > java version "1.7.0_51" > Java(TM) SE Runtime Environment (build 1.7.0_51-b13) > Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode) > > -- > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.