On Wed, Dec 22, 2010 at 12:52 PM, Rayne <disciplera...@gmail.com> wrote:

> Running it gives me around 137343.295 nanoseconds. I've seen some Java
> algorithms that could run at just under 3000 nanoseconds.
>

What do the Java implementations look like?

(defn count-num-chars [^String s]
  (let [l (.length s)
        c (int \space)]
   (loop [i 0 acc 0]
    (if (< i l)
      (recur (unchecked-inc-long i)
             (if (= (int (.charAt s i)) c) acc
                 (unchecked-inc-long acc)))
      acc))))

On 1.3.0 alpha3 on a 2.66ghz Core i7, 64bit OS X JDK 1.6 I see anywhere
from-

6900ns-11000ns

Using identical?, codePointAt all make things slower for me.

David

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

Reply via email to