On Fri, Aug 7, 2009 at 9:19 PM, Andy Fingerhut <
andy_finger...@alum.wustl.edu> wrote:

> > What I suggest is
> >
> > (loop [zr (double 0.0)
> >        zi (double 0.0)
> >        i (int (inc iterations-remaining))]
> >   (let [zr2 (* zr zr)
> >         zi2 (* zi zi)]
> >     (if (and (not (= 0 i)) (< (+ zr2 zi2 limit-square)))
> >        (recur (+ (- zr2 zi2) pr) (+ (* (* f2 zr) zi) pi) (unchecked-inc
> i))
> >        (whatever...))))
> >
> > * Same calculations
> > * Less items in recur rebind
> > * Counter is also primitive
> >
> > (untested, may need slight tweakage)
>
> Needed unchecked-dec in place of unchecked-inc, and I used (zero? i)
> instead of (= 0 i) (not sure if that makes much difference), and the
> results are much better -- the time went down to a little less than
> half of what it was before.


Try (= 0 i) or whatever. Since zero? is a function it's probably boxing the
integer, unless it's a definline rather than a defn.

http://github.com/jafingerhut/clojure-benchmarks/blob/fe10ef25ec17b77dd03f6d1ccff4f35273764f3b/RESULTS


Why post a link to a blank web page?


> Thanks!
> Andy
>

You're welcome.

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