Do I always have to think about performance?

后端 未结 21 744
小蘑菇
小蘑菇 2021-02-04 04:16

I come from a DBA world and performance has always been an obsession. I am turning to development and I always think about performance, constantly, all the time.

Reading

21条回答
  •  情话喂你
    2021-02-04 04:48

    I'm going to disagree with the pack here to some degree.

    You always consider performance--but that consideration is usually to dismiss it. Look at how often the code will run. If the answer is "once" or "rarely" performance is basically a non-issue.

    Only when a piece of code is going to execute frequently do you need to pay attention to performance. Even in this case you generally should only look at the O() class of the routine until profiling shows a problem.

    The only time I will consider anything like detailed optimization when I'm originally writing is code inside an O(scary) routine. (Example: A test to ensure a set of data contained no dead ends. O(n^8), although with substantial pruning. I was careful of performance from the first line.)

提交回复
热议问题