5 Premature optimization vs. optimizing the hot path: Decisions that impact code performance

This chapter covers

  • When premature optimization is evil
  • Finding the hot path in your code using performance testing and measurements
  • Optimizing the hot path

There is an old computer science saying that premature optimization is the root of all evil. This has a solid background because it’s accurate for a lot of use cases. Without any input data about expected traffic and a service level agreement (SLA), it’s hard to reason about your code and its required performance. Optimizing random paths in code in such a situation is like shooting in the dark. You will complicate your code without a sane reason.

Note SLA specifies the amount of traffic the service ...

Get Software Mistakes and Tradeoffs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.