Recent conversations with colleagues have produced varying points of view on this matter. What say you, SO members?
I know, even the concept of scalability can be taken in so many different ways and contexts, but that was part of the discussion when this came up. Everyone seemed to have a different take on what scalability really means. I'm curious to see the varying takes here as well. In fact, I posted a question just for that concept.
I would guess that the best way to check is by writing benchmarks, but in my opinion LINQ has the possibility for optimizations that hand-writing similar code does not. I don't know how well it takes advantage of those yet.
LINQ lets you express what you want, not how to generate it. One obvious advantage is that LINQ is automatically parallelizable (see PLINQ).
Another advantage to LINQ is that it is lazy, so you can perform calculations, drawing from the collection as needed. You could hand-code an equivalent, but it may be much easier to get right in LINQ.
In tests we did, LINQ to objects (ForEach) was about 2x times slower then foreach loop.
LINQ to SQL (MS SQL Database) is almost 10x slower than direct query using data reader, using most of the time creating SQL from expression tree (so, you'll be CPU bound and Database will be idling) To avoid this, you must use compiled queries.
See this for more. Most info in the post is still valid with .NET 3.5 SP1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With