On Aug 10, 12:41 pm, fft1976 <fft1...@gmail.com> wrote: > I just uploaded to the group an implementation of the n-body benchmark > in Clojure (see nbody_init.clj) > > http://shootout.alioth.debian.org/u32/benchmark.php?test=nbody〈=j... > > My goal was to write a pure-functional version and to avoid any micro- > optimizations. There are no type declarations and plenty of laziness > and higher-order functions. > > It seems to be 100 times slower than Java (I was expecting worse) on > my machine, putting it in the same class as Ruby, Perl and Python > (which are imperative). > > The obvious things to do next here, in the order of ugliness, are: > > 1. switch to 3D vectors instead of arbitrary length functions > 2. add type declarations > 3. avoid maps > 4. experiment with adding/removing "(vec ..." > 5. get imperative or transient > 6. switch to Java arrays/classes > > I am curious about how much more "non-idiomatic" Clojure has to become > here for each step it takes towards Java-like performance in this > benchmark, and whether the most optimized version will match Java in > speed. > > I hope others can pick this up and implement the optimizations, or > post their timings.
I'm not going to start optimising, but I don't think there's a need to avoid maps. You could use struct maps and generate accessors for the base keys... but somehow I doubt that is the bottleneck -- Jarkko --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---