Hi.

I've made a dumb (very dumb) performance comparison function just to play
with the language.
I wanted to mark some symbols with a float primitive type but the compiler
complained so I had to annotate it with the Float class.
Here is the function:

(defn dumb-test []
  (let [#^Float f2 567.09723]
    (loop [#^Float f 1.8, i 10000000]
      (if (zero? i)
        f
        (recur (/ f f2) (dec i))))))

And the test:

(loop [i 50]
  (time (dumb-test))
  (if (zero? i)
    i
    (recur (dec i))))

There's a way to put a float primitive type in the metadata to prevent the
Float -> float unboxing?
Feel free to point some mistakes I probably made, I've just started learn
clojure.

The clojure version took an average: "Elapsed time: 217.833342 msecs" in my
machine.

The java version (below) took average 23 msecs:

private static float dumbTest() {
        float f = 1.8f;
        float f2 = 567.09723f;
        for(int i = 0; i < 10000000; i++) {
            f /= f2;
        }
        return f;
    }

Regards.
Islon

--~--~---------~--~----~------------~-------~--~----~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to