How To Optimize
Donald Knuth:
(Source is here. See the 2nd paragraph on the right column on page 8.)
We should forget about small efficiencies, say about 97% of thetime: premature optimization is the root of all evil. Yet weshould not pass up our opportunities in that critical 3%.
Here's the general advice on optimizing:
1. Don't do it
2. Don't do it yet
3. Don't do it until someone complains that it is slow.
4. And when someone complains, find the bottleneck - measure it! Get a feel of how slow it is. Remember:
Don't optimize what you cannot measure because therein lies the road to insanity.
5. Optimize one step at a time and always, always measure the gain. If there's no gain then undo your "optimization".
0 Comments:
Post a Comment
<< Home