﻿<?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>Dathan Bennett commented on UberProf performance improvements, beware of linq query evaluation</title><description>@MF, ToArray() might be slightly faster, but list item access by index is constant-time, so the difference (if there is an appreciable one) is probably trivial.
</description><link>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment14</link><guid>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment14</guid><pubDate>Fri, 22 Jan 2010 17:40:02 GMT</pubDate></item><item><title>MF commented on UberProf performance improvements, beware of linq query evaluation</title><description>would .ToArray() be slightly faster? or am i missing something?
</description><link>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment13</link><guid>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment13</guid><pubDate>Tue, 12 Jan 2010 03:51:05 GMT</pubDate></item><item><title>david commented on UberProf performance improvements, beware of linq query evaluation</title><description>You asked 3 questions in your posting. I don't know the definitive answer to them. To aid those, like me, who come along in the future and read posts like this, it would be beneficial to see questions and answers -- rather than just questions. 
  
  
Comprendes?
</description><link>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment12</link><guid>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment12</guid><pubDate>Tue, 05 Jan 2010 09:45:41 GMT</pubDate></item><item><title>Ayende Rahien commented on UberProf performance improvements, beware of linq query evaluation</title><description>Not sure that I am following you here
</description><link>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment11</link><guid>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment11</guid><pubDate>Tue, 05 Jan 2010 05:41:29 GMT</pubDate></item><item><title>david commented on UberProf performance improvements, beware of linq query evaluation</title><description>@Ayende: so, are you going to fill in the the "just back from holiday, and brain slow to fire up" and the "too scared to comment in case I look foolish" amongst us? :-)
</description><link>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment10</link><guid>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment10</guid><pubDate>Tue, 05 Jan 2010 02:26:41 GMT</pubDate></item><item><title>Konstan commented on UberProf performance improvements, beware of linq query evaluation</title><description>@John: would you be happier if your saw IEnumerable
&lt;statement instead of var?
  
  
var is good because it allows compiler to pick the best matching extension method (for example IEnumerable and IQueryable both have "Where" extension method but first performs filtering on client whereas second does it on server - shorter code with performs better - win-win situation)
&gt;</description><link>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment9</link><guid>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment9</guid><pubDate>Tue, 29 Dec 2009 03:00:29 GMT</pubDate></item><item><title>Mike Chaliy commented on UberProf performance improvements, beware of linq query evaluation</title><description>@firefly, agree but LINQ full of such technics... It all about lazy. So I believe we already prepared for this klind of stuff.
</description><link>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment8</link><guid>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment8</guid><pubDate>Fri, 25 Dec 2009 09:57:22 GMT</pubDate></item><item><title>firefly commented on UberProf performance improvements, beware of linq query evaluation</title><description>@Mike Memoization is a very powerful technique for performance optimization... Unfortunately it's something that could take awhile for an OO programmer to bend his head around to. Unless you are coming from a functional background :) Then it become your second nature.
</description><link>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment7</link><guid>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment7</guid><pubDate>Fri, 25 Dec 2009 00:10:39 GMT</pubDate></item><item><title>Mike Chaliy commented on UberProf performance improvements, beware of linq query evaluation</title><description>Probably Rx has better solution compared to the ToList(). System.Interactive.dll has MemoizeAll method. It cashes results, but works in lazy manner. I have blog post about this 
[chaliy.name/.../system_interactive_new_and_usef...](http://chaliy.name/blog/2009/12/system_interactive_new_and_useful_linq_extensions_to_ienumerable)</description><link>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment6</link><guid>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment6</guid><pubDate>Thu, 24 Dec 2009 22:28:59 GMT</pubDate></item><item><title>John Chapman commented on UberProf performance improvements, beware of linq query evaluation</title><description>This is actually one of the reasons I find var to be mostly evil.  var allows developers to ignore the real type.  It changes the mind of thinking.  The two pieces of code do VERY different things.  Yet to an untrained eye it's not clear at all.  Largely I blame var for this.  If the type were explicitly defined in that statement I believe fewer people would make the mistake of misunderstanding how it is being used.
  
  
I personally never use var in my code.  That also means I never use anonymous types.  I don't mind the extra typing involved.  Typing doesn't take a long time.  Forming the right solution to the problem is usually the much biggest cost, so typing cost is in the noise for me.  Readability adds more.
  
  
I realize I'm in the minority on this subject.
</description><link>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment5</link><guid>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment5</guid><pubDate>Thu, 24 Dec 2009 17:27:48 GMT</pubDate></item><item><title>JJoos commented on UberProf performance improvements, beware of linq query evaluation</title><description>I agree with rik, and i wouldn't do it because the performance issues are probably in the first part.
</description><link>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment4</link><guid>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment4</guid><pubDate>Thu, 24 Dec 2009 16:39:03 GMT</pubDate></item><item><title>Anthony Dehirst commented on UberProf performance improvements, beware of linq query evaluation</title><description>NumberOfStatements is 
  
statements.Count() - NumberOfCahcedStatements - NumberOfTransactionsStatements;
  
I guess that you didn't do it as it would make the code a little messier as you couldn't use the inline constructor. I do hope that there is a better reason.
</description><link>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment3</link><guid>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment3</guid><pubDate>Thu, 24 Dec 2009 15:38:13 GMT</pubDate></item><item><title>John St. Clair commented on UberProf performance improvements, beware of linq query evaluation</title><description>"group by" rather than count, and a join/group by for the agreegate number of statements?
</description><link>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment2</link><guid>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment2</guid><pubDate>Thu, 24 Dec 2009 12:15:10 GMT</pubDate></item><item><title>Rik Hemsley commented on UberProf performance improvements, beware of linq query evaluation</title><description>I'd say the obvious 'optimization' would be to take counts of statements which are transactions, which are cached and which are neither.
  
  
Something like this...
  
  
long cachedCount, transactionCount, neitherTransactionNorCachedCount;
  
  
statements.Each(s =&gt;
  
  {
  
    cachedCount += s.IsCached ? 1 : 0;
  
    transactionCount += s.IsTransaction ? 1 : 0;
  
    neitherTransactionOrCachedCount += s.IsCached || s.IsTransaction ? 0 : 1;
  
  }
  
  
Not sure why you'd avoiding doing it, but I'm on holiday and my brain's not in gear. That's my excuse, anyway.
  
</description><link>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment1</link><guid>http://ayende.com/4337/uberprof-performance-improvements-beware-of-linq-query-evaluation#comment1</guid><pubDate>Thu, 24 Dec 2009 11:25:58 GMT</pubDate></item></channel></rss>