I replaced the calls to get-in with a my-get-in macro that "compiled" them to nested calls on the map or vector:
(my-get-in sle [:A 1 2]) => (((sle :A) 1) 2) The form (data key) seems to be about 10 to 15 times faster than the equivalent (get-in data [key]) on my laptop. It cut the runtime in half or so. I would think that floating point operations might be faster, too. On Oct 9, 6:38 am, "andi.xeno...@googlemail.com" <andi.xeno...@googlemail.com> wrote: > Hi, > > I'm new to Clojure, and let me first say that I love it! At least I > love the language, but I have some concerns regarding performance: > > My first try was to implement a Gauß elemination algorithm for solving > a system of linear equations. Here is the code: > > http://www.xenoage.com/extern/zongblog/matrix.clj > > Solving 1.000.000 SLEs (see last line) took 33.000 ms on my machine, > while the corresponding algorithm written in Java needed less than 300 > ms. > > Since I am a Java programmer and I have no experience in functional > programming, I probably have to apologize for the bad code. Anyway, I > already tried to make it faster using the well-known performance tips > (like type hints), but they did not really help (ok, 25.000 ms instead > of 33.000, but it is still too much). > > What are my options? > - Can you identify problems in my code? I do not mean things that make > it 10% faster, but at least double as fast. > - Could you say, that Clojure is not made for such numerical things, > and I should use Java code for these performance-critical algorithms? > (would be perfectly ok for me) > - Should I try it in Clojure, but using a (mutable) Java array instead > (also ok for me, since this mutable structure is only used locally and > within a single thread) > > Any ideas? Thanks in advance :-) > > Andi -- 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