Hi, I am trying to compare the performance of java loops to clojure reduce function. Noting special, Since I am just learning. Java code is something like:
[code] long sum = 0; for (int i = 1; i < 1000000; i++ ){ sum = sum + i; } [/code] while in Clojure I used: [code] (reduce + (range 1 i)) [/code] Execution time for the Java version is 7 ms, while Clojure needs 60 - 160 ms. Now, that is expected, since Clojure runs in REPL. Next, I tried the gen-class of the Clojure, and called that Class from Java (so no REPL involved), but the code haven't speed up at all! Am I missing something or such 10x performance penalty is usual for such operations? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---