I've been benchmarking java and clojure programs and wanted to make sure I was doing this right. I made two fairly similar programs that manipulated Vec2 objects from the JBox2D library. At first clojure was performing pretty poorly, then I tried compiling my clojure script, and then replacing the inner doseq with a loop. But java is still 5x faster and I hear that clojure should be able to run as fast as java and I wondered if there's any options in clojure I'm not using
Java: package test; import org.jbox2d.common.Vec2; public class Main { static long w = 0; public static void main(String[] args) { for(int q = 0;q < 5;q++){ Vec2 a = new Vec2(1, 2), b = new Vec2(3, 4); long start = System.currentTimeMillis(); for(int d = 0;d < 1e9;d++){ a.addLocal(b); } long stop = System.currentTimeMillis(); System.out.println((stop - start)/1000.0); } } } Clojure: (ns hello.test (import org.jbox2d.common.Vec2) (:gen-class)) (defn -main [& args] (doseq [q (range 5)] (let [a (Vec2. 1 2) b (Vec2. 3 4)] (time (loop [x (int 0)] (when (< x 1e9) (.addLocal a b) (recur (unchecked-inc x)))))))) Vec2(if anyone cares): http://code.google.com/p/jbox2d/source/browse/trunk/jbox2d/src/org/jbox2d/common/Vec2.java -- 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