Tag Archives: Performance

Introducing CloneExtensions .NET cloning library

I’ve spent last two days working on my first open source .NET library named CloneExtensions. It gives you a smart way to clone your object instances without implementing any interface writing any additional Clone method at all. It uses Expression Tree to compile that Clone method for you right before you’re trying to use GetClone for given type T for the first time.
Continue reading Introducing CloneExtensions .NET cloning library

Partitioning the collection using LINQ: different approaches, different performance, the same result

Another blog post inspired by StackOverflow question. This time it’s all about LINQ, performance and a tiny little detail, that really matters. The question itself is about yield keyword in VB.NET, but there is another, much more interesting part I’d like to examine. The algorithm quoted in the question is the key.

The idea is simple. How to partition a collection into parts with given number of elements in ever part? Algorithm presented in the question is as easy as the questions seems to be:
Continue reading Partitioning the collection using LINQ: different approaches, different performance, the same result

Why (or when) you should/shouldn’t use Descendants() method

A lot of LINQ to XML questions on StackOverflow are being answered using Descendants() method calls. It looks like most of people think it’s the best way to handle and query XML document: it’s easy to use, you don’t have to worry about whole tree structure. It just works. But are these solutions really good ones? Is Descendants() method really that good as it seems to be? I would say: NO! I think common LINQ to XML queries should not use Descendants(). I’ll try to answer it shouldn’t be used in this blog post.
Continue reading Why (or when) you should/shouldn’t use Descendants() method

Convert class, IConvertible interface and Generics – deep dive into performance

First non LINQ-related question on my blog, but another one in response to great StackOverflow question: Casting generic parameter to and from integer. Every day you can find something that inspires you to do your own research and think hard why things work like they do. That’s exciting, isn’t it?

Getting back to question. Author posted following code and simply asked, how can it be done better?
Continue reading Convert class, IConvertible interface and Generics – deep dive into performance

Did you know about that LINQ feature? I guess you didn’t!

First of all, I have to say thank you! to Toto for Most optimized use of multiple Where statements StackOverflow question and hatchet for really great answer, which made me write this blog post.

The question is simple: does LINQ optimize multiple Where calls? I think most people would say no. I did say no too! Google says no * unless you dig really deep! But what is the correct answer to that question? Continue reading Did you know about that LINQ feature? I guess you didn’t!