Assault by GC

added by Noldorin
10/27/2011 8:12:33 AM

4 Kicks, 103 Views

Well-known .NET developer Marc Gravell details how he eliminated some performance problems through clever use of structures, and explains how the CLR garbage collector behaves.


10/27/2011 10:24:49 AM
I've also swapped out classes for structs and lists for arrays before and noticed a significant performance improvement in the code I was working with (tight loop, lot's of data processing).
I feel this is a good example for avoiding premature optimization: They went the correct route here and wrote good, clean, object-oriented code up-front; When they discovered a bottle-neck their good practices allowed them to segregate that section of code, perform the optimizations they listed, all without effecting any of the other code.

10/27/2011 6:37:02 PM
I agree... Well all know premature micro-optimisation is a bad thing, and really micro-optimisation of *any sort* in a high-level language like C# should be well-commented. Most of the time one either doesn't care about the performance benefits, or they're simply negligible given the effort required to make them/reduction in readability of code. Even when I do have to micro-optimise, I personally try to abstract the nasty stuff away into a separate module, if possible.