Answering my own question, my issues were 1) overlooking a couple seqs that 
were thousands of times slower than vectors, and 2) using / instead of 
quot. Just found this video:

http://www.infoq.com/presentations/Crunching-Numbers-Clojure

I'm finding that seqs are pretty much always too slow, but they are 
returned by many of the core functions. Consequently my code is getting 
littered with (vec ...) calls. Am I doing this wrong? Does everyone have 
(vec ...) calls all over their code? 

On Saturday, October 20, 2012 7:27:56 PM UTC-7, Brian Craft wrote:
>
> I have a vector of maps representing intervals with (start, end) coords in 
> one dimension, that are non-overlapping, and sorted. At the moment I'm not 
> using a sorted data type, just a vector.
>
> The bottleneck in my code is in searching for intervals that overlap a 
> region, like so:
>
> (defn filter-probe-range [probes start end]
>   (filter #(and (> (:end %) start) (< (:start %) end)) probes))
>
> My first thought to speed it up was to add a binary search on the vector, 
> since it's sorted. However, that is wildly slower than doing a full scan 
> with filter. I'm not sure why that is, or how to investigate it. I've 
> looked over the section on performance in "The Joy of..", but nothing is 
> really popping out. Should I start with jvisualvm? Is there something 
> better that would identify what I'm doing that's so slow?
>
> Also wondering if sorted data types would do this for me for free. Is 
> there a way to do a binary search on a sorted collection?
>

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