# 軟件最佳化

提示：呢篇文講嘅唔係數學最佳化

## 基礎概念

``` a = 200; # 設 a 做 200
while (a > 0)  # 可以睇埋 while 迴圈嘅概念。
{
b = 10;
if (a % b == 0} # 如果 a 係 b 嘅倍數，print a 出嚟睇。
print(a);
a -= 1; # a 數值下降 1
}
```

``` a = 200;
b = 10;
while (a > 0)
{
if (a % b == 0}
print(a);
a -= 1;
}
```

`b = 10` 呢個步驟就變成淨係做一次咁多，令到段碼效率高咗。軟件最佳化指緊嘅就係[2]:p. 1[5]

 「 要減少一個程式消耗嘅資源量，當中『資源量』包括－ 碼嘅數量、 行起上嚟嘥嘅時間，同埋 行起上嚟嘥嘅記憶體量， 同時保持個程式功能唔變。 」

## 文獻

• Abelson, H., & Sussman, G. J. (1996). Structure and interpretation of computer programs. The MIT Press.
• Gorelick, M., & Ozsvald, I. (2020). High Performance Python: Practical Performant Programming for Humans. O'Reilly Media.
• Code Optimization (PDF). University of California, Davis, Computer Science Lecture Notes.

## 攷

1. Wadleigh, K. R., & Crawford, I. L. (2000). Software optimization for high-performance computing. Prentice Hall Professional.
2. Code Optimization (PDF). University of California, Davis, Computer Science Lecture Notes.
3. Lowry, E. S., & Medlock, C. W. (1969). Object code optimization (PDF). Communications of the ACM, 12(1), 13-22.
4. Code Optimization in Compiler Design. GeeksForGeeks. 1. Code Motion or Frequency Reduction, Example.
5. 5 Most Complex Software Ever 互聯網檔案館歸檔，歸檔日期2022年10月8號，.. JavaScript in Plain English.