It's noteworthy that this behavior again changes after advanced builds. There is a related ticket here:
https://dev.clojure.org/jira/browse/CLJS-2038 It's probably best to avoid redefining recursive functions for anything non-dev stuff. - Andre On Monday, October 24, 2016 at 1:31:13 AM UTC+2, Aravindh Johendran wrote: > > Hi Mike, > > Thanks. Yes, it is the exact same issue because of call to shadowing local > symbol. Memoization, tracing, etc. are iimpacted by this. > Seems to me this is an optimization and shouldn't be default behavior. > > > (defn fib1 [n] > (if (< n 2) > n > (+ (fib1 (dec n)) > (fib1 (dec (dec n)))))) > > (defn fib2 [n] > (if (< n 2) > n > (+ (cljs.user/fib2 (dec n)) > (cljs.user/fib2 (dec (dec n)))))) > > On Replete repl and iPad Pro: > > (time (fib1 20)) > "Elapsed time: 2.000000 msecs" > 6765 > > (time (fib2 20)) > "Elapsed time: 3.000000 msecs" > 6765 > > => (time (fib1 35)) > "Elapsed time: 1491.000000 msecs" > 9227465 > > => (time (fib2 35)) > "Elapsed time: 2159.000000 msecs" > 9227465 > > => (time (fib1 38)) > "Elapsed time: 6335.000000 msecs" > 39088169 > > => (time (fib2 38)) > "Elapsed time: 9162.000000 msecs" > 39088169 > > > I'll play around with performance numbers on Planck with static fns etc. > later. > > -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/clojurescript.
