John, this will speed up to the same as the others if you let the 0. IIRC
from looking at the bytecode before, the 0 is an Integer not an int.
user> (time
(let [m (int 100000000) b (double 4.0) x0 (double -0.2) y0 (double
0.1) t (double 2.0) i0 (int 0)]
(loop [x (double 0.0) y (double 0.0) i m]
(if (> i i0)
(let [x2 (* x x) y2 (* y y)]
(if (< (+ x2 y2) b)
(recur (+ (- x2 y2) x0) (+ (* t (* x y)) y0)
(unchecked-dec i))
i))
i))))
"Elapsed time: 881.387889 msecs"
0
-Mike
On Tue, Aug 11, 2009 at 10:00 PM, John Harrop <[email protected]> wrote:
> user=> (time (let [m (int 100000000) b (double 4.0) x0 (double
> -0.2) y0 (double 0.1) t (double 2.0)]
> (loop [x (double 0.0) y (double 0.0) i m]
> (if (> i 0)
> (let [x2 (* x x) y2 (* y y)]
> (if (< (+ x2 y2) b)
> (recur (+ (- x2 y2) x0) (+ (* t (* x y)) y0)
> (unchecked-dec i))
> i))
> i))))
> "Elapsed time: 3418.8542 msecs"
> 0
>
> Shockingly, reversing the count-up to a count-down and not changing
> anything else at all makes things much, MUCH worse, about four times slower.
>
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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
-~----------~----~----~----~------~----~------~--~---