On Jul 1, 6:24 pm, "Heinz N. Gies" <he...@licenser.net> wrote: > One reason here is that clojures literals as 1 2 and 3 you use for array > indexes are longs, the aget methods want int's
Agreed. If we can take the profiling snapshot I linked to at face value, the boxing and casting adds up to ~40% of the CPU time. Given that the speed difference between Java arrays in Java and in Clojure is ~9x (900%), there are probably other factors here as well. Just note that the REPL timings you are listing are for N=50 million. My "18s vs 2s" timings are from the command line with N=500 million and include JVM startup time. (So that I could compare it to plain Java.) But your private fix apparently got the relative speed difference down to ~8x, which is an improvement. Regards jf On Jul 1, 6:24 pm, "Heinz N. Gies" <he...@licenser.net> wrote: > > I did: > > "Java arrays 18s" is Java arrays in Clojure. > > "Plain Java 2s" is Java arrays in Java. > > One reason here is that clojures literals as 1 2 and 3 you use for array > indexes are longs, the aget methods want int's so you've funny casting there > which is slow for comparison I've done it on a private test thingy where I > use longs as array indexes: > > user=> (time-mtype) > (5000000.00 10000000.00 15000000.01) > Bye from Clojure > "Elapsed time: 245.152 msecs" > nil > user=> (time-type) > (5000000.00 10000000.00 15000000.01) > Bye from Clojure > "Elapsed time: 1360.897 msecs" > nil > user=> (time-arr) > (5000000.00 10000000.00 15000000.01) > Bye from Clojure > "Elapsed time: 2029.323 msecs" > nil > > Regards, > Heinz -- 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