Tuesday, December 15, 2009

Performance Issues

I have been part of software projects where we constantly have to tune the code (C#/SQL) for performance improvements. The question you have to ask yourself before doing any code change for performance is "Does this code really warrant changes for performance issues"? Most of the time someone would say changing the code to use LINQ instead of for each loop would make it faster.. Most of the time such recommendations tend to be wrong. Write code that is readable/maintainable before thinking too much about the performance issues.

Always, Always measure your performance problems before and after making code changes to conclude that you have impacted code in a positive way. Even though this principal applies for both code that is in active development and production, it is critical in case of code that has already been deployed to production.

One of my favorite c# blogger John Skeet wrote an excellent article on this topic. He sums it up real nice in one line "Performance is important - too important to be guessed about instead of measured."