¿Es la optimización previa la raíz de todos los males?







Este artículo es una reacción a otro artículo El rendimiento es lo primero . Sí, en Internet de nuevo alguien se equivoca. Sin embargo, quiero ir más allá del alcance del tema en discusión para complementar y profundizar la consideración de aspectos importantes.







Artículo original de Knuth



Por supuesto, Knut no necesita a nadie que lo proteja. De hecho, ¿quién es Knut y quién soy yo? Sin embargo, mi objetivo no es proteger a Knut, sino proteger el sentido común.







, . , : http://cowboyprogramming.com/files/p261-knuth.pdf







, 1974 “ GOTO” ( ). , . , , .







, , GOTO. . 1974. , : GOTO .







, , GOTO . GOTO , — .







:







2.







A[m+1] := x; i := 1;
while A[i] != x do i := i + 1;
if i > m then m := i; B[i] := 1;
else B[i] := B[i] + 1 fi;
      
      





2a.







A[m+1] := x; i := 1; go to test;
loop:  i := i + 2;
test:  if A[i] = x then go to found fi;
       if A[i+1] != x then go to loop fi;
       i := i + 1;
found: if i > m then m := i; B[i] := 1;
       else B[i] := B[i] + 1 fi;
      
      





2 12%, .. . .







. . .

, . : ?







:







There is no doubt that the grail of efficiency leads to abuse. Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.



, . , , . , , 97% : — .

.. — , . , , :







  1. , .
  2. : .
  3. , .


, . , . , . , . , .







, . , , - . , , . — , .







“ ?”



, . , , : ?







, — . , , . : . , . . , . .







: ?







: ! , , .







, .









. , ? : . , ( ) . , , , .







, , . , , : , , , .. , , , :







  1. ? ?
  2. ? ? ?
  3. ? /.
  4. ?
  5. ?
  6. ..


— : “ ?”.







. . , .







, -, , , . , PHP/Python, . , .









, , , .







, : .







? ? - , . , . , . , .. .







. , , , , , .., . . . .









. — , .







, : — . , , .







? . . , , , , , , . , , .







: . .







.








All Articles