﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Iván Morales commented on The RavenDB indexing process: Optimization&amp;ndash;Parallelizing work</title><description>Definitely not my day today. 

I made a mistake when typing the name of the test that ran. These are the corrected results and much more logical;-)

[Count&gt;0] 0.22 secs, [Count()&gt;0] 0.86 secs (x3,91 slower then the fastest), [Any()] 4.97 secs (x22,58 slower then the fastest)

Thanks Phil</description><link>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment14</link><guid>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment14</guid><pubDate>Thu, 19 Apr 2012 21:23:46 GMT</pubDate></item><item><title>Phil Bolduc commented on The RavenDB indexing process: Optimization&amp;ndash;Parallelizing work</title><description>@Ivan - I took your souce can and ran my own analysis.  I could not corroborate your results. My code is here: http://pastebin.com/QadafRKG  

One thing I added was to allow the user to pick which order the tests run.  I also ran a smaller batch before timing to remove any issues with CPU caches.  I ran this on Windows 7 x64 SP1, 16GB RAM, Q9400 @ 2.66GHz, .NET Framework 4 Client Profile

Here are my results:

D:\&gt;CountAnalysis.exe any-method-property
Overhead: 415
Any: 15250
CountMethod: 5877
CountProperty: 304

D:\&gt;CountAnalysis.exe method-property-any
Overhead: 413
CountMethod: 5877
CountProperty: 303
Any: 14274

D:\&gt;CountAnalysis.exe property-any-method
Overhead: 413
CountProperty: 303
Any: 15391
CountMethod: 5878

D:\&gt;CountAnalysis.exe any-property-method
Overhead: 414
CountProperty: 303
Any: 15082
CountMethod: 5893</description><link>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment13</link><guid>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment13</guid><pubDate>Thu, 19 Apr 2012 19:16:55 GMT</pubDate></item><item><title>stu commented on The RavenDB indexing process: Optimization&amp;ndash;Parallelizing work</title><description>@Phil 
"Ayende is using the Count property, not the Count() extension method."
yeah I noticed that ... afterwards</description><link>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment12</link><guid>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment12</guid><pubDate>Thu, 19 Apr 2012 17:08:08 GMT</pubDate></item><item><title>Iván Morales commented on The RavenDB indexing process: Optimization&amp;ndash;Parallelizing work</title><description>My test code: http://pastebin.com/awGgJpn9

</description><link>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment11</link><guid>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment11</guid><pubDate>Thu, 19 Apr 2012 15:50:39 GMT</pubDate></item><item><title>Phil Bolduc commented on The RavenDB indexing process: Optimization&amp;ndash;Parallelizing work</title><description>@Iván could you elaborate on the testing? What was the data type, i.e., List&lt;T&gt;, that you used? How many items were in your collection? I think the stackoverflow link that @Simon provided has a good explaination. 

Using JustDecompile, the Count property on List&lt;T&gt; has the following definition:  public int Count { get { return this._size; } } which is returning a private field.  The Count() extension method at minimum needs to check if the underlying collection is an ICollection&lt;T&gt; or ICollection.  If so, it returns the Count property.  It does at minimum one not null check, one cast to ICollection&lt;T&gt; using 'as', and one Count property access.

Generally, if the collection is an ICollection&lt;T&gt; the argument of using the Count() extension method or Count property is moot.</description><link>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment10</link><guid>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment10</guid><pubDate>Thu, 19 Apr 2012 14:58:02 GMT</pubDate></item><item><title>Iván Morales commented on The RavenDB indexing process: Optimization&amp;ndash;Parallelizing work</title><description>Oppps again. Today is not my day :-(

Ordered from faster to slower: 
Count() [Method] -&gt; Count [Property] -&gt; Any() [Method]

The fastest way:
Count() [Extension Method]

Count [Property] is slower than Count()
Any() [Extension Method] is much slower then Count property</description><link>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment9</link><guid>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment9</guid><pubDate>Thu, 19 Apr 2012 14:35:02 GMT</pubDate></item><item><title>Iván Morales commented on The RavenDB indexing process: Optimization&amp;ndash;Parallelizing work</title><description>Phil my previous comment you can results from Count property too

My results (without filtering data) ordered from faster to slower: Any() [Method] -&gt; Count [Property] -&gt; Count() [Method]</description><link>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment8</link><guid>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment8</guid><pubDate>Thu, 19 Apr 2012 14:29:59 GMT</pubDate></item><item><title>Phil Bolduc commented on The RavenDB indexing process: Optimization&amp;ndash;Parallelizing work</title><description>@Ivan/@Stu: Ayende is using the Count property, not the Count() extension method.</description><link>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment7</link><guid>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment7</guid><pubDate>Thu, 19 Apr 2012 14:16:42 GMT</pubDate></item><item><title>Simon commented on The RavenDB indexing process: Optimization&amp;ndash;Parallelizing work</title><description>Any() definitely can be faster in certain circumstances - as always though, it depends...

Good answer here: http://stackoverflow.com/a/305156/54222</description><link>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment6</link><guid>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment6</guid><pubDate>Thu, 19 Apr 2012 13:37:34 GMT</pubDate></item><item><title>Iván Morales commented on The RavenDB indexing process: Optimization&amp;ndash;Parallelizing work</title><description>Upps, time is in seconds, not milliseconds.</description><link>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment5</link><guid>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment5</guid><pubDate>Thu, 19 Apr 2012 13:27:33 GMT</pubDate></item><item><title>Iván Morales commented on The RavenDB indexing process: Optimization&amp;ndash;Parallelizing work</title><description>I made some simple tests and these are the results:
0.1461996 ms. [x1.00] Count()&gt; 0
0.6240561 ms. [x4.27] Count&gt; 0
5.0751038 ms. [x34.71] Any()

The Count method is the fastest.
In other test Count property is 4-6 times slower then Count() and Any() 30-50 times slower


</description><link>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment4</link><guid>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment4</guid><pubDate>Thu, 19 Apr 2012 13:12:45 GMT</pubDate></item><item><title>Stu commented on The RavenDB indexing process: Optimization&amp;ndash;Parallelizing work</title><description>doh ! 
I thought I was helping as well 
A quick google came back with 
http://stackoverflow.com/questions/305092/which-method-performs-better-any-vs-count-0 and http://stackoverflow.com/questions/5741617/listt-any-or-count

So I'm guessing FindIndexesFor(doc) returns a List not an IEnumerable 

Sorry ;-)</description><link>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment3</link><guid>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment3</guid><pubDate>Thu, 19 Apr 2012 11:34:18 GMT</pubDate></item><item><title>Ayende Rahien commented on The RavenDB indexing process: Optimization&amp;ndash;Parallelizing work</title><description>Stu,
Huh? There is no way Any can be faster.</description><link>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment2</link><guid>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment2</guid><pubDate>Thu, 19 Apr 2012 11:29:58 GMT</pubDate></item><item><title>Stu commented on The RavenDB indexing process: Optimization&amp;ndash;Parallelizing work</title><description>;-)
Would you get any more performance if you switch to 
".Any()" instead of ".Count &gt; 0" ?</description><link>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment1</link><guid>http://ayende.com/155233/the-ravendb-indexing-process-optimization-parallelizing-work#comment1</guid><pubDate>Thu, 19 Apr 2012 11:29:02 GMT</pubDate></item></channel></rss>