wordfor

pre·ma·ture op·ti·mi·za·tion

/ˌpriː.məˈtʃʊr ˌɑːp.tɪ.məˈzeɪ.ʃən/ (pree-muh-CHOOR op-tih-mih-ZAY-shun) noun

Software design

  1. Spending effort making code fast before knowing, by measurement, that it is a bottleneck. The team hand-tuned a loop that took 2 ms while a 900 ms database query went unnoticed.

Origin

From Donald Knuth's 1974 paper 'Structured Programming with go to Statements': 'premature optimization is the root of all evil'.

In practice

Profile before optimising. Knuth's next sentence matters too: do not pass up the critical 3%.

Say to your AI

Write the simplest correct version first. Don't optimise anything until we have a benchmark showing where the time goes.

In plain words

  • making it fast before it works
  • optimizing code that isn't slow
  • micro-optimizing without profiling

See also YAGNI (you aren't gonna need it) technical debt

Find similar words