Optimizing Code

You are given a heap of code in your favorite language which combines to form a rather complicated application. It runs rather slowly, and your boss has asked you to optimize it. What are the steps you follow to most efficiently optimize the code?

What strategies have you found to be unsuccessful when optimizing code?

Re-writes: At what point do you decide to stop optimizing and say "This is as fast as it'll get without a complete re-write." In what cases would you advocate a simple complete re-write anyway? How would you go about designing it?


Profile before attempting any optimisation.

9 times out of 10, the time won't be consumed where you might guess it is.

The usual unsuccessful strategy is micro-optimisation, when what is actually required is the appropriate algorithm.

Obligatory Donald Knuth quote:

"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil"

Need Your Help

Need to learn how to set appropriate permissions on SQL Server database to allow Syncronisation through Sync Framework 2.1

sql permissions sync microsoft-sync-framework

Please exuse my ignorance but SQL Server is not my strong point and I start to get lost when going past the basic Create Table, Select from Table etc.

sql average of a sum divided by a count

sql count sum average

I am trying to do an SQL query to get the average spend for a specific customer.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.