On Aug 11, 4:42 am, fft1976 <fft1...@gmail.com> wrote:
> On Aug 10, 11:42 pm, Jonathan Smith <jonathansmith...@gmail.com>
> wrote:
>
> > The way your code is setup, you will spend a lot of time in funcall
> > overhead just because you used a lot of functions instead of doing the
> > calculation in bigger chunks.
>
> I thought, as I understood from Rich's lectures, JVM inlines whatever
> it wants.

Up to a certain size of chunk of code. Things do get faster if you run
them a couple times, certainly, but you need to give it a good size
block of smallish functions to really take effect with the in-lining.
To my knowledge it won't inline a map or reduce yet.

> Anyway, I put everything inside a LET. In my tests my normal
> code (nbody_v2.clj) is 55x slower than Java, and yours is 40x slower.
> Andy's transients-using and type-declaring version is 37x slower (in
> his tests). After I put everything inside a LET, I get to be 52x
> slower than Java. Definitely not worth it, considering how ugly it is.
>

I don't think you have to put *everything* in the let, just your
constants. (so days per year and solar mass, the bodies themselves).

I don't know about ugly one way or another, but I mostly do the 'fns
in a let' thing to keep my code organized and structured. I only want
certain things to be external in the package... (And other things I
want to pre-compute...)

> Your version is not pure-functional, right? If so, I think I still
> have the fastest pure-functional and non-type declaring version.
>

Ok, sure.

> Let's just say that hacking Clojure's implementation of destructuring
> is against the rules. If it were a good idea, I'm sure Rich would have
> done it by now.

I didn't hack destructuring, I made a small change to whether or not
'nth' expands into an inline form in a certain case. It does actually
make a big difference on code that does a lot of destructuring.
--~--~---------~--~----~------------~-------~--~----~
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