16.6. Measuring Performance
I don’t like to place too much emphasis on optimizing for speed. The best way to do this in general is to select a reasonable algorithm and use common sense.
Certainly speed matters. In some cases it matters greatly. But it is usually a mistake to worry about speed too soon in the development cycle. The saying goes, “Premature optimization is the root of all evil.” (This originated with Hoare and was restated by Knuth.) Or as someone else put it: “Make it right, then make it fast.” At the application level, this is generally a good heuristic (though at the level of large systems, it may be of less value).
I would add to this precept: Don’t optimize until you measure.
That isn’t so much to ask. Refrain from refactoring ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access