I\'ve been struggling with an application I\'m writing and I think I\'m beginning to see that my problem is premature optimization. The perfectionist side of me wants to mak
We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. -- Hoare
While @John Saunders nails it, applying TDD alone might not completely addresses your concerns. I adhere to TDD, and when you do TDD correctly, and if you can apply refactoring effectively, you typically end up with much leaner code, and with the benefit that you know it works. No arguments there.
However, I see too many developers write performance-ignorant code - avoiding premature optimization is no excuse for writing sloppy / lazy / naive code. Writing unit tests doesn't prevent this. Although someone who writes unit tests is probably a better coder, and better coders are less apt to write bad code as often.
Do write tests, and do include performance testing into your suite of tests for the scenarios your stakeholders identify. e.g. retrieve 100 discounted products for a specific vendor, and include stocking levels and format as Xml in under 3 seconds
The fallacy that "premature optimization" is the same thing as "concern about performance" should not guide software development. -- Randall Hyde
If you leave performance concerns too late, you may find it's too hard, or too costly to change.
Some articles