幾款PHP框架性能對比(Zend、CakePHP、Yii等)
案例
本次測試輸出簡單的hello word,簡單MVC邏輯,(Router -> Controller -> Viewer),沒有數(shù)據(jù)庫連接,沒有任何邏輯.
硬件平臺
- CPU: Intel Core i5 750 (2.67GHz x4)
- RAM: 4GB
軟件環(huán)境
Debian 6.0.4 x86_64 (2.6.32-41)
apache 2.2.16 (mpm-prefork,mod-php5)
php 5.3.10
php-apc 3.1.9 (Optimization for include/require)
Copy all projects to /dev/shm/* (Optimization for files read/write)
PHP框架列表
* zf: Zend Framework
Site: http://framework.zend.com
Ver: 1.11.11
* zf2: Zend Framework
Site: http://framework.zend.com
Site: https://github.com/zendframework/ZendSkeletonApplication
Ver: 2.0.0-beta1
* symfony: symfony
Site: http://www.symfony-project.org
Ver: 2.0.0
* cakephp: CakePHP
Site: http://cakephp.org
Ver: 2.0.4
* ci: CodeIgniter
Site: http://codeigniter.com
Ver: 2.1.0
* yii: Yii Framework
Site: http://www.yiiframework.com
Ver: 1.1.8
* micromvc4: MicroMVC
Site: http://www.micromvc.com
Ver: 4.0.0
* laravel: Laravel, A PHP Framework For Web Artisans
Site: http://laravel.com
Ver: 2.0.2
* slim: Slim Framework
Site: http://www.slimframework.com
Ver: 1.5.0
* yaf: Yet Another Framework in PHP Extension
Site: http://code.google.com/p/yafphp
Ver: 2.1.3-beta (yaf.cache_config=1)
* FuelPHP: Simple, Flexible, Community driven Web Framework
Site: http://fuelphp.com/
Ver: 1.1
* ColaPHP:
Site: http://code.google.com/p/colaphp/
Ver: 1.2-ga
# XHProf: A Hierarchical Profiler for PHP
Site: http://pecl.php.net/xhprof
Ver: 0.9.2
# The source code of this testing:
Source: https://github.com/eryx/php-framework-benchmark
1. Apache Benchmark
Requests pre second (-c 100 -n 30000), the bigger is better
請求/秒(-c 200 -n 50000), 數(shù)值越大越好
2. 系統(tǒng)負(fù)載
壓力測試一分鐘內(nèi)完成的負(fù)載圖
越小越好(-c 100 -n 30000)
3. 內(nèi)存使用率
測試hello word占用的內(nèi)存,越小越好.
4. 響應(yīng)時間
頁面的響應(yīng)時間.單位微妙
5. 調(diào)用方法的數(shù)量(Facebook XHProf)
單個hello word頁面調(diào)用了多少方法,zend5620個方法,是不是太臃腫了。
6. 文件數(shù)量
打開hellow word用到included or required in 文件的數(shù)量.越小越好,zend很多,yii19個,yaf才4個,不快才怪。