On Aug 18, 6:50 am, David Nolen <dnolen.li...@gmail.com> wrote: > The Clojure code posted there is pretty awful and shows a gross, gross > misunderstanding of Clojure data types. I submitted one improved version > already, but didn't spend the time to make it really, really fast. > > For this particular kind of pointless benchmark it's not hard to get > identical Java perf. If you want to see how I suggest you look at the Alioth > benchmarks where the Clojure code shows a much better understanding of the > language and the fast paths and where the microbenchmarks are quite so > micro.
I'm sure you meant to say - "I suggest you look at the Alioth benchmarks where the Clojure code shows a much better understanding of the language and the fast paths and where the microbenchmarks are " - not - " quite so micro." :-) As it happens, back in 2005 when trying to come up with new tasks for what would become the benchmarks game, I considered trying something based on the Josephus problem as a replacement for the old Doug Bagley "List processing" task. http://web.archive.org/web/20040805114635/http://www.bagley.org/~doug/shootout/bench/lists/ But it just seemed perverse not to solve such a simple problem with an array and integer add/subtract like this - public static int countoffSoldiers(int n, int kth) { int[] soldiers = new int[n]; for (int i = 0 ; i < n ; i++) soldiers[i] = i+1; //int k = kth-1, survivedLastRound = n; // standard Josephus problem int k = 0, survivedLastRound = n; while (survivedLastRound > 1) { int survived = 0; for (int i = 0 ; i < survivedLastRound; i++) if (i != k) { soldiers[survived++] = soldiers[i]; } else { k += kth; } k -= survivedLastRound; // wrap around survivedLastRound = survived; } return soldiers[0]; } > >http://java.dzone.com/articles/contrasting-performance -- 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