雲端伺服器可隨意切換作業系統,筆者以單核 Xeon E5620 + 1GB RAM 環境,分別部署 Windows 2003 (IIS+MySQL+PHP) 與 CentOS 5.9 (Apache+MySQL+PHP),執行相同含資料庫查詢的 PHP 程式測試執行時間。
$st = microtime(true); // ... 含 MySQL 查詢邏輯 ... echo "載入時間:" . (microtime(true) - $st);
| 測試次 | Windows 2003 (秒) | CentOS 5.9 (秒) | 倍數差距 |
|---|---|---|---|
| 1 | 0.0197 | 0.0113 | 1.74x |
| 2 | 0.0119 | 0.0052 | 2.29x |
| 3 | 0.0148 | 0.0047 | 3.15x |
註:測試環境較舊,現代 PHP 7/8 + Nginx + PHP-FPM 在 Linux 上效能差距更大。