Re: Amap vs Map performance

2010-07-08 Thread Harvey Hirst
With 1.2:

(set! *warn-on-reflection* true)
(time (amap an-array idx ret (+ (int 1) (aget an-array idx
Reflection warning, NO_SOURCE_PATH:52 - call to aclone can't be resolved.
Reflection warning, NO_SOURCE_PATH:52 - call to alength can't be resolved.
Reflection warning, NO_SOURCE_PATH:52 - call to aget can't be resolved.
Reflection warning, NO_SOURCE_PATH:52 - call to aset can't be resolved.
"Elapsed time: 2663.612 msecs"

Type hinting the arrays:
(time (amap ^ints an-array idx ret (+ (int 1) (aget ^ints an-array idx
"Elapsed time: 11.443 msecs"

Whenever you see unusually slow performance reflection is frequently the
cause.
Not sure about the 1.1/1.2 performance though.

Harvey
-- 
"You're keeping me alive because you don't know DOS?"
Izzy, Prophecy II

-- 
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

Re: Extremely silly benchmarks, on types, records and maps.

2010-05-12 Thread Harvey Hirst
It's slow because it has to use reflection to determine the type.
Use (set! *warn-on-reflection* true) and you'll see the warning.

Try something like this and you'll see significantly faster results:

(let [#^testType t (new testType 1 2 3)]
  (time (dotimes [_ 1000] (.a t)))

Harvey
-- 
"You're keeping me alive because you don't know DOS?"
Izzy, Prophecy II

-- 
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


Re: Missing fns: rotate & rotate-while

2010-04-22 Thread Harvey Hirst
> (defn rotate [n s]
>  (let [[front back] (split-at (mod n (count s)) s)]
>    (concat back front)))

Don't forget (mod n 0) is an ArithmeticException.

Harvey

-- 
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