This won't get you all of the way to Java speeds, or at least it didn't for me, 
but try these things:

Use:

(set! *warn-on-reflection* true)
(set! *unchecked-math* true)

The first won't speed anything up, but it will warn you about some things that 
are slow.

The second will use unchecked match wherever it can, meaning primitive 
operations on arithmetic values like longs, that will silently wrap instead of 
checking for overflow.  Java doesn't check for overflow in primitive 
operations, either.

Also use aset instead of aset-int.  I don't know why, but the aset-* operations 
are typically slower than aset, as long as the type hints on the aset arguments 
are good enough.

I got within 4x Java speed with those changes.

Andy


On Feb 18, 2013, at 8:16 PM, Geo wrote:

> Hello,
> 
> I am cross-posting my Clojure question from StackOverflow.  I am trying to 
> get an algorithm in Clojure to match Java speed and managed to get the 
> performance to within one order of magnitude and wondering if more is 
> possible. The full question is here:
> 
> http://stackoverflow.com/questions/14949705/clojure-performance-for-expensive-algorithms
> 
> Thank you.

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to