Performance

Knuth's Optimization Principle

Measure before you optimize — programmers spend time optimizing non-critical code.

performance optimization design

Donald Knuth emphasized that developers often waste enormous time thinking about the speed of non-critical parts of their programs.

Best Practice

  1. Write correct, readable code first
  2. Profile and identify actual bottlenecks with tools (not intuition)
  3. Optimize only the hot paths that profiling reveals
  4. Re-measure to confirm your optimization actually helped

Intuition about performance is frequently wrong. Let data drive your optimization decisions.

Enforce this law (and 100+ more) in your AI coding agents with DevLaws.

Open DevLaws All laws →