OK, I tried this. Object field access instead of arrays made a few percent difference, but not enough to be significant.
Definterface and defprotocol, on the other hand, not only gave cleaner code but was more than twice as fast. A huge win if you ask me :) So summarizing this particular benchmark: * 1.1 style optimization using primitive Java arrays peaks at ~4x slower than Java. * 1.2 style optimization using mutable primitive fields in a deftype is only ~1.7x (70%) slower than Java. Links: * more detail including profiling snapshots, JVM version etc. http://wiki.github.com/j-g-faustus/Clojure-test-code/ * 1.2 implementation: http://github.com/j-g-faustus/Clojure-test-code/blob/master/shootout/nbody_type.clj I haven't tried the new numeric branches, there seems to be a sufficient number of people with opinions on those already :) But I can add the observation that it is possible to write very fast numeric code in the 1.2 master branch as it stands today. Possibly non- idiomatically by using mutable fields, but still fast, still Clojure and far cleaner than the 1.1 optimizations. Thanks for the deftype tip. Regards jf On Jun 27, 6:03 pm, Nicolas Oury <nicolas.o...@gmail.com> wrote: > You could be more idiomatic and probably faster with 1.2's (definterface > Body-ish (x[]..). x= ...) and the like with type annotations (or better > with protocols, but they have no annotations yet, I think) > and (deftype Body [x y ...] Body-ish ....). > Object field access are a bit faster than array access on the jvm. (as a > first try, you could mesure the difference with using the Body class from > java and the main loop in clojure, to check where the > difference comes from) > > Best regards, > > Nicolas. -- 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