On 2010/12/23 18:30, Ken Wesson wrote:

> On Thu, Dec 23, 2010 at 3:24 AM, Remco van 't Veer <rwvtv...@gmail.com> wrote:
>> Simpler and faster:
>>
>>  (count (clojure.string/replace s " " ""))
>
> Simpler, yes, but not at all faster:
>
> Time (in nanoseconds): 120485.9396
>
> This is about comparable to the slow, unoptimized loop posted at the
> start of this thread. Frankly, I'm surprised it's not even worse since
> it creates a whole extra string object on top of that.

On my system it is about 10x faster than the code in the original
thread.  Together with the amount of time saved writing it, it's full
seconds, maybe even minutes faster!  I guess your nanoseconds and are
not my nanoseconds..  ;)

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