<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-7259600127580558466.post6094646797337157683..comments</id><updated>2009-03-13T02:55:41.540-07:00</updated><title type='text'>Comments on Sergio's devlog: Performance tips for Clojure</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://devlog.bigmonachus.org/feeds/6094646797337157683/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7259600127580558466/6094646797337157683/comments/default'/><link rel='alternate' type='text/html' href='http://devlog.bigmonachus.org/2009/03/performance-tips-for-clojure.html'/><author><name>Sergio</name><uri>http://www.blogger.com/profile/14484987086950947832</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7259600127580558466.post-1199057784637143958</id><published>2009-03-13T02:55:00.000-07:00</published><updated>2009-03-13T02:55:00.000-07:00</updated><title type='text'>You create a list of one single element, namely th...</title><content type='html'>You create a list of one single element, namely the said range. Try to remove the list or use list* in your benchmark and you will get similar results to the vector. (Of course mapping over one element is faster than mapping over one million)&lt;BR/&gt;&lt;BR/&gt;Creating a seq on something is O(1), not O(n). The collection is not turned somehow into a seq, but the seq is an abstract view on the collection.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7259600127580558466/6094646797337157683/comments/default/1199057784637143958'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7259600127580558466/6094646797337157683/comments/default/1199057784637143958'/><link rel='alternate' type='text/html' href='http://devlog.bigmonachus.org/2009/03/performance-tips-for-clojure.html?showComment=1236938100000#c1199057784637143958' title=''/><author><name>mb</name><uri>http://www.blogger.com/profile/11266441093818691397</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://devlog.bigmonachus.org/2009/03/performance-tips-for-clojure.html' ref='tag:blogger.com,1999:blog-7259600127580558466.post-6094646797337157683' source='http://www.blogger.com/feeds/7259600127580558466/posts/default/6094646797337157683' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-7259600127580558466.post-3275483008033695469</id><published>2009-03-12T23:56:00.000-07:00</published><updated>2009-03-12T23:56:00.000-07:00</updated><title type='text'>(def ls (list (range 1000000)))(def vc (vec (range...</title><content type='html'>(def ls (list (range 1000000)))&lt;BR/&gt;(def vc (vec (range 1000000)))&lt;BR/&gt;&lt;BR/&gt;(time (dorun (map (fn [x]) ls)))&lt;BR/&gt;"Elapsed time: 3.184435 msecs"&lt;BR/&gt;&lt;BR/&gt;(time (dorun (map (fn [x]) vc)))&lt;BR/&gt;"Elapsed time: 498.535303 msecs"&lt;BR/&gt;&lt;BR/&gt;I was based on something like that. Probably the extra time taken is from converting the vector to a seq. That would still make it O(n) right? It would just be for another reason.&lt;BR/&gt;&lt;BR/&gt;Maybe you are getting similar performance because you didn't use dorun and map returns a lazy seq.&lt;BR/&gt;&lt;BR/&gt;Thanks, I'll edit the post.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7259600127580558466/6094646797337157683/comments/default/3275483008033695469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7259600127580558466/6094646797337157683/comments/default/3275483008033695469'/><link rel='alternate' type='text/html' href='http://devlog.bigmonachus.org/2009/03/performance-tips-for-clojure.html?showComment=1236927360000#c3275483008033695469' title=''/><author><name>Sergio</name><uri>http://www.blogger.com/profile/14484987086950947832</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09353262483281693312'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://devlog.bigmonachus.org/2009/03/performance-tips-for-clojure.html' ref='tag:blogger.com,1999:blog-7259600127580558466.post-6094646797337157683' source='http://www.blogger.com/feeds/7259600127580558466/posts/default/6094646797337157683' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-7259600127580558466.post-937763444581669330</id><published>2009-03-12T23:45:00.000-07:00</published><updated>2009-03-12T23:45:00.000-07:00</updated><title type='text'>rest is an operation on seqs. A list is a seq, but...</title><content type='html'>&lt;I&gt;rest&lt;/I&gt; is an operation on seqs. A list is a seq, but a vector is not. When &lt;I&gt;map&lt;/I&gt; is given a vector, it first creates a seq on it. The &lt;I&gt;rest&lt;/I&gt; operation on that seq is O(1). In some quick micro-benchmarking, the performance of iterating &lt;I&gt;identity&lt;/I&gt; many thousands of times over a list or vector of a few hundred items gave very similar performance. I'm interested in what you see in the code or in a test that suggests that &lt;I&gt;map&lt;/I&gt; performs much better over a list than over a vector.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7259600127580558466/6094646797337157683/comments/default/937763444581669330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7259600127580558466/6094646797337157683/comments/default/937763444581669330'/><link rel='alternate' type='text/html' href='http://devlog.bigmonachus.org/2009/03/performance-tips-for-clojure.html?showComment=1236926700000#c937763444581669330' title=''/><author><name>squeegee</name><uri>http://www.blogger.com/profile/02744110455629077693</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://devlog.bigmonachus.org/2009/03/performance-tips-for-clojure.html' ref='tag:blogger.com,1999:blog-7259600127580558466.post-6094646797337157683' source='http://www.blogger.com/feeds/7259600127580558466/posts/default/6094646797337157683' type='text/html'/></entry></feed>