If you ask most developers what it means to have performance optimal code, they'll typically respond by saying "it runs really fast". But, the question that follows that statement should be whether or not the code is "fast enough". How do you, the developer, know how fast is fast enough? This is where a goal-setting acronym will perfect fit in: SMART.
- S - specific
- M - measurable
- A - attainable
- R - repeatable
- T - tested to destruction
You know if your code is "fast enough" when it is SMART:
- Does your code meet a specific response time goal?
- Can you measure the response time and resource consumption easily and reliably?
- Is the response time goal really attainable (trying to get back 10 billion rows from database in 1 second just may not ever be physically possible)?
- Can you repeatedly meet the response time objective as data volumes, number of users, etc. increases?
- Have you tested your code to cover all reasonable scenarios under which it may execute?
To answer all these questions and to determine if your code is SMART requires a disciplined and well-designed approach. If you have successfully achieved SMART code, you can be reasonably assured that you'll have performance optimal code.