<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: LINQ vs Loop &#8211; A performance test</title>
	<atom:link href="http://ox.no/posts/linq-vs-loop-a-performance-test/feed" rel="self" type="application/rss+xml" />
	<link>http://ox.no/posts/linq-vs-loop-a-performance-test</link>
	<description>Håvard Stranden's website</description>
	<lastBuildDate>Tue, 02 Mar 2010 07:41:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ray</title>
		<link>http://ox.no/posts/linq-vs-loop-a-performance-test/comment-page-1#comment-601</link>
		<dc:creator>Ray</dc:creator>
		<pubDate>Sat, 12 Sep 2009 04:03:35 +0000</pubDate>
		<guid isPermaLink="false">http://ox.no/posts/linq-vs-loop-a-performance-test#comment-601</guid>
		<description>&lt;p&gt;My code for Linq:&lt;/p&gt;

&lt;p&gt;for (int t = 0; t &lt; RUNS; ++t)
 {
        int[] less = ints.Where(i =&gt; i &lt; 10).ToArray();
 }&lt;/p&gt;

&lt;p&gt;My result:
LINQ: 00:00:00.0936002, avg. 00:00:00.0000936
Loop: 00:00:00.1092002, avg. 00:00:00.0001092&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>My code for Linq:</p>

<p>for (int t = 0; t &lt; RUNS; ++t)
 {
        int[] less = ints.Where(i =&gt; i &lt; 10).ToArray();
 }</p>

<p>My result:
LINQ: 00:00:00.0936002, avg. 00:00:00.0000936
Loop: 00:00:00.1092002, avg. 00:00:00.0001092</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Kaufman</title>
		<link>http://ox.no/posts/linq-vs-loop-a-performance-test/comment-page-1#comment-531</link>
		<dc:creator>Eric Kaufman</dc:creator>
		<pubDate>Fri, 15 May 2009 19:38:48 +0000</pubDate>
		<guid isPermaLink="false">http://ox.no/posts/linq-vs-loop-a-performance-test#comment-531</guid>
		<description>&lt;p&gt;Just wanted to add in that with .Net 4.0 they&#039;re upgrading the compiler, and adding parallelism for LINQ queries, which I expect will change things out a lot. For those of you who did hop on the LINQ train, I would imagine that a lot of your queries might just start to work a bit quicker once the new compiler comes out.&lt;/p&gt;

&lt;p&gt;http://www.betanews.com/article/Everyone-talk-at-once-NET-40-will-include-Parallel-Extensions/1223931673&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Just wanted to add in that with .Net 4.0 they&#8217;re upgrading the compiler, and adding parallelism for LINQ queries, which I expect will change things out a lot. For those of you who did hop on the LINQ train, I would imagine that a lot of your queries might just start to work a bit quicker once the new compiler comes out.</p>

<p><a href="http://www.betanews.com/article/Everyone-talk-at-once-NET-40-will-include-Parallel-Extensions/1223931673" rel="nofollow">http://www.betanews.com/article/Everyone-talk-at-once-NET-40-will-include-Parallel-Extensions/1223931673</a></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://ox.no/posts/linq-vs-loop-a-performance-test/comment-page-1#comment-529</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Sat, 09 May 2009 18:29:11 +0000</pubDate>
		<guid isPermaLink="false">http://ox.no/posts/linq-vs-loop-a-performance-test#comment-529</guid>
		<description>&lt;p&gt;This function does nothing, and thus benchmarking a compiled version is dangerous (so is benchmarking a debug version, but less so).  A compiler will happily say, &quot;This loop does nothing! Let&#039;s skip it!&quot; I&#039;d be hesitant to trust any benchmarks that are not in use on production code...though they&#039;re a nice tool for developers of compilers to use to check if their optimizations are working.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>This function does nothing, and thus benchmarking a compiled version is dangerous (so is benchmarking a debug version, but less so).  A compiler will happily say, &#8220;This loop does nothing! Let&#8217;s skip it!&#8221; I&#8217;d be hesitant to trust any benchmarks that are not in use on production code&#8230;though they&#8217;re a nice tool for developers of compilers to use to check if their optimizations are working.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: JS</title>
		<link>http://ox.no/posts/linq-vs-loop-a-performance-test/comment-page-1#comment-509</link>
		<dc:creator>JS</dc:creator>
		<pubDate>Wed, 25 Feb 2009 21:08:27 +0000</pubDate>
		<guid isPermaLink="false">http://ox.no/posts/linq-vs-loop-a-performance-test#comment-509</guid>
		<description>&lt;p&gt;If you run the compiled verision of the application (.exe or .dll), LINQ actually runs faster&lt;/p&gt;

&lt;p&gt;running out of VS is not a valid test and should not be compared.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>If you run the compiled verision of the application (.exe or .dll), LINQ actually runs faster</p>

<p>running out of VS is not a valid test and should not be compared.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Venkat</title>
		<link>http://ox.no/posts/linq-vs-loop-a-performance-test/comment-page-1#comment-508</link>
		<dc:creator>Venkat</dc:creator>
		<pubDate>Mon, 16 Feb 2009 04:47:19 +0000</pubDate>
		<guid isPermaLink="false">http://ox.no/posts/linq-vs-loop-a-performance-test#comment-508</guid>
		<description>&lt;p&gt;All the times in ms.&lt;/p&gt;

&lt;p&gt;I run the tests as Pavol suggested.&lt;/p&gt;

&lt;p&gt;LINQ: 1, avg. 24
Loop: 92, avg. 1322&lt;/p&gt;

&lt;p&gt;from int i / from i, There is no much difference&lt;/p&gt;

&lt;p&gt;LINQ: 247, avg. 3803
Loop: 89, avg. 1286&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>All the times in ms.</p>

<p>I run the tests as Pavol suggested.</p>

<p>LINQ: 1, avg. 24
Loop: 92, avg. 1322</p>

<p>from int i / from i, There is no much difference</p>

<p>LINQ: 247, avg. 3803
Loop: 89, avg. 1286</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Håvard</title>
		<link>http://ox.no/posts/linq-vs-loop-a-performance-test/comment-page-1#comment-507</link>
		<dc:creator>Håvard</dc:creator>
		<pubDate>Wed, 07 Jan 2009 21:56:31 +0000</pubDate>
		<guid isPermaLink="false">http://ox.no/posts/linq-vs-loop-a-performance-test#comment-507</guid>
		<description>&lt;p&gt;Brian: Interesting, with 3.5 SP1 I get the following results:&lt;/p&gt;

&lt;p&gt;With explicit int:
Linq .446 Loop .231&lt;/p&gt;

&lt;p&gt;And without the explicit int:
Linq .431 Loop .256&lt;/p&gt;

&lt;p&gt;This could indicate that Cast() is optimized away in SP1, but I have not verified this.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Brian: Interesting, with 3.5 SP1 I get the following results:</p>

<p>With explicit int:
Linq .446 Loop .231</p>

<p>And without the explicit int:
Linq .431 Loop .256</p>

<p>This could indicate that Cast() is optimized away in SP1, but I have not verified this.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://ox.no/posts/linq-vs-loop-a-performance-test/comment-page-1#comment-498</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Tue, 09 Dec 2008 21:10:01 +0000</pubDate>
		<guid isPermaLink="false">http://ox.no/posts/linq-vs-loop-a-performance-test#comment-498</guid>
		<description>&lt;p&gt;I ran the same test and didn&#039;t get the same results&lt;/p&gt;

&lt;p&gt;Linq .20
Loop .08&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I ran the same test and didn&#8217;t get the same results</p>

<p>Linq .20
Loop .08</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Bart</title>
		<link>http://ox.no/posts/linq-vs-loop-a-performance-test/comment-page-1#comment-490</link>
		<dc:creator>Bart</dc:creator>
		<pubDate>Thu, 23 Oct 2008 22:56:57 +0000</pubDate>
		<guid isPermaLink="false">http://ox.no/posts/linq-vs-loop-a-performance-test#comment-490</guid>
		<description>&lt;p&gt;An update using the latest service packs and running the same code as in your blog: the LINQ query is 5 - 6 times slower than the loop on my machine.&lt;/p&gt;

&lt;p&gt;However, the LINQ query is probably 5 - 6 times more understandable than the loop for someone reading the code and trying to figure out what it&#039;s doing.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>An update using the latest service packs and running the same code as in your blog: the LINQ query is 5 &#8211; 6 times slower than the loop on my machine.</p>

<p>However, the LINQ query is probably 5 &#8211; 6 times more understandable than the loop for someone reading the code and trying to figure out what it&#8217;s doing.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Robert</title>
		<link>http://ox.no/posts/linq-vs-loop-a-performance-test/comment-page-1#comment-393</link>
		<dc:creator>Robert</dc:creator>
		<pubDate>Sun, 02 Mar 2008 22:00:09 +0000</pubDate>
		<guid isPermaLink="false">http://ox.no/posts/linq-vs-loop-a-performance-test#comment-393</guid>
		<description>&lt;p&gt;Wow, building in release, Loop is 10x faster than Linq without doing the int cast.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Wow, building in release, Loop is 10x faster than Linq without doing the int cast.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: john</title>
		<link>http://ox.no/posts/linq-vs-loop-a-performance-test/comment-page-1#comment-360</link>
		<dc:creator>john</dc:creator>
		<pubDate>Fri, 22 Feb 2008 15:08:32 +0000</pubDate>
		<guid isPermaLink="false">http://ox.no/posts/linq-vs-loop-a-performance-test#comment-360</guid>
		<description>&lt;p&gt;Pavol - the ToArray appears to take so long as the query is only executed at this point. Deferred query execution in LINQ means the query is only executed when you iterate through the query result (e.g. by calling ToArray). declaring and initialising the query doesn&#039;t execute the query, but this initialisation probably accounts for the shorter time (2ms) you&#039;ve seen.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Pavol &#8211; the ToArray appears to take so long as the query is only executed at this point. Deferred query execution in LINQ means the query is only executed when you iterate through the query result (e.g. by calling ToArray). declaring and initialising the query doesn&#8217;t execute the query, but this initialisation probably accounts for the shorter time (2ms) you&#8217;ve seen.</p>]]></content:encoded>
	</item>
</channel>
</rss>
