LINQ Performance - In Memory Collection - Hilton Giesenow's Jumbled Mind

Hilton Giesenow's Jumbled Mind

the madness that is...

News

This is my little spot in cyberspace where you will find a collection of random (but mostly software-related) thoughts and ideas that are frightening in their shining brilliance (or something like that ;->).
 
Please enjoy your stay and feel free to Contact Me.
 
Microsoft MVP

.Net Links

BlogRoll

Misc. Links

Syndication

LINQ Performance - In Memory Collection

Steve Herbert has an interesting performance evaluation discussion up on his blog (this is raw LINQ, by the way, not LINQ to SQL). Initially, he has 3 samples, the first 2 using LINQ and the 3rd without. These are the results:

Item#1 – averaged 2643 ms
Item#2 – averaged 671 ms
Item#3 – averaged <1 ms

However, make sure to read through the comments on the post. What emerges is from Eric Lee who comments:

"So the lesson to learn here is that when you use Linq, you either need to make sure your container implements IQueryable or be prepared for IEnumerable-based algorithm performance ...  How could Linq possibly know how to take advantage of the quirks of every conceivable data structure? Obviously it can't.  It has its own strategy that works against anything that can manage to implement IEnumerable, and it can take advantage of custom strategies if they're provided via IQueryable."

The list of structures and frameworks that implement IQueryable include LINQ To SQL, LINQ To Datasets, LINQ To XML, LINQ To Amazon, LINQ To SharePoint, LINQ To Active Directory, LINQ To Flickr, LINQ To NHibernate, LINQ To REST, even an attempt at LINQ To Google Desktop and I'm sure there are more coming.

For a discussion on LINQ To SQL performance, see my post on this.

Posted: Feb 12 2008, 11:26 AM by hiltong | with 2 comment(s)
Filed under:

Comments

Rudi Grobler said:

I am currently sitting at Cape Town airport and as usual our flight is delayed, so I decided to use this

# February 22, 2008 7:19 AM

Hilton Giesenow's Jumbled Mind said:

I mentioned in a post a little while ago about the various LINQ To projects I had seen, but Charlie Calvert

# March 19, 2008 7:05 AM