On Thursday, July 3, 2014 5:19:56 PM UTC+1, adrian...@mail.yu.edu wrote: > > You're going down a rabbit hole here. Evaluating forms at runtime will > always result in a slower execution time than a function that doesn't > evaluate a form at runtime. >
I thought that was the whole point of Clojure? The REPL is just parsing a string or file and running (eval) on it, I can't detect any difference in speed when doing it manually: (quick-bench ((fn fac [x] (if (zero? x) 1 (* x (fac (dec x))))) 10)) ; => 263 ± 9 ns (eval `(quick-bench ((fn fac# [x#] (if (zero? x#) 1 (* x# (fac# (dec x#))))) 10))) ; 269 ± 8 ns I'm very sure that the differences I measured are only because the lists are being copied instead of passed by reference, which I can understand in the case where the disassembly actually shows a copy being constructed. But not in the case where the bytecode is exactly the same --- and criterium takes a lot of time to warm up etc, all of the same optimisations should have been applied (and the dynamic part of the code is not a lot anyway, it's just calling AOT-compiled java code anyway. The only difference in timing must stem from the element-wise comparison) -- 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.