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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.