You should profile your code. A cousin of mine was solving a problem from programmingchallenges.com in C++. I wrote a solution in Clojure. At the beginning, my version was astronomically slower. After profiling, I reduced it to about 2x slower. After modifying it to use Java arrays, it actually became as fast or faster than my cousin's C++ solution.
See this question I posted a while ago: http://groups.google.com/group/clojure/browse_thread/thread/4d8356465b294e44/7cd4facb86a04f64?hl=en&lnk=gst&q=profilers I ended up preferring the JVisualVM profiler that comes with the JVM. Clojure is more than fast enough. It's just extremely easy to write very, very slow code. On Mar 12, 12:48 am, tristan <tristan.k...@gmail.com> wrote: > Hi guys, > > I'm loving Clojure, but i'm having a lot of trouble writing programs > in it that run as fast as my python equivalents. > One example is code i've written for projecteuler.net problem 87 (for > those who don't want to see any solutions don't click the links > below :)) > my python > versionhttp://github.com/tristan/project-euler-code/blob/4a17bc271b4b2743ee1... > runs in ~4 seconds (timed using cygwin "time python 0087.py" whereas > my clojure > versionhttp://github.com/tristan/project-euler-code/blob/4a17bc271b4b2743ee1... > takes over 20 seconds (time gotten from (time call in the code). This > is quite disheartening for me as well since i wrote the python version > in about a minute and haven't even thought about optimizations yet. It > was just written as a test since i was unhappy with the speed of my > clojure version even after re-writing it a few times and shaving off > about 20 seconds from my original. > > I'm sure there must be something i'm doing wrong, or thinking wrongly > about hence why i'm not getting the speed i need. Can anyone suggest > any alternate ways to write this? or anything to speed it up? I really > enjoy programming in Clojure, but speed is starting to become an issue > with me. > > Thanks > -Tristan --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---