On Sat, Mar 13, 2010 at 1:59 PM, CuppoJava <patrickli_2...@hotmail.com>wrote:

> Hi,
> I just ran these two microbenchmarks, where I attempted to measure the
> overhead in Clojure's loop-recur form as compared to just mutating an
> array.
>
> ;;loop-recur (5300 msecs)
> (time
>  (dotimes [n 5000]
>    (loop [accum (int 0) i (int 0)]
>      (if (< i 50000)
>        (recur (+ accum i) (inc i))
>        accum))))
>

; ~720ms
(time
 (dotimes [n 5000]
   (loop [accum (int 0) i (int 0)]
     (if (< i (int 50000))
       (recur (+ accum i) (inc i))
       accum))))

You have to remember that even number literals need to be type-hinted.

David

-- 
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

Reply via email to