When is optimisation premature?

前端 未结 20 1241
悲哀的现实
悲哀的现实 2020-11-21 23:26

As Knuth said,

We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.

20条回答
  •  自闭症患者
    2020-11-22 00:12

    When programming, a number of parameters are vital. Among these are:

    • Readability
    • Maintainability
    • Complexity
    • Robustness
    • Correctness
    • Performance
    • Development time

    Optimisation (going for performance) often comes at the expense of other parameters, and must be balanced against the "loss" in these areas.

    When you have the option of choosing well-known algorithms that perform well, the cost of "optimising" up-front is often acceptable.

提交回复
热议问题