Hello everybody,
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"
Python 3.0:
>>> import timeit
>>> t=timeit.Timer('sum(fac(n) for n in range(1000))', 'from functools import
>>> reduce; from operator import mul; fac = lambda n: reduce(mul, range(1,
>>> n+1), 1)')
>>> t.timeit(10)/10
0.35052159800038679
This is XP SP2 on Core2 Duo, with 3Gb of RAM.
As you can see, Python is almost 3 times faster on this
microbenchmark! Can anybody explain this to me? (No flame wars,
please, I am really interested in why the things are as they are, is
it considered ok or not, and what can be done to make Clojure faster
on similar tests).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---