The type hints aren't really helping there, I think. #^Float might
help if you were calling a Java function and wanted to avoid the
runtime reflection lookup cost, but you're only calling Clojure
functions so it doesn't help.
On my machine, about 180 msecs
To get unboxed primitives, you have to do more like what Parth did:
> (defn dumb-test []
> (let [f2 (float 567.09723)]
> (loop [f (float 1.2), i (long 10000000)]
> (if (zero? i)
> f
> (recur (/ f f2) (dec i))))))
On my machine that's 48 msecs.
But we can do a bit better, just by using unchecked-dec:
(defn dumb-test []
(let [f2 (float 567.09723)]
(loop [f (float 1.2), i (long 10000000)]
(if (zero? i)
f
(recur (/ f f2) (unchecked-dec i))))))
That's 24 msecs for me.
But I don't know how useful these kinds of micro-benchmarks really
are. Clojure's "fast enough" so let's go solve some interesting
problems...
--Chouser