几款PHP框架性能对比(Zend、CakePHP、Yii等)
案例
本次测试输出简单的hello word,简单MVC逻辑,(Router -> Controller -> Viewer),没有数据库连接,没有任何逻辑.
硬件平台
- CPU: Intel Core i5 750 (2.67GHz x4)
- RAM: 4GB
软件环境
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:
Ver: 1.11.11
* zf2: Zend Framework
Site:
Site:
Ver: 2.0.0-beta1
* symfony: symfony
Site:
Ver: 2.0.0
* cakephp: CakePHP
Site:
Ver: 2.0.4
* ci: CodeIgniter
Site:
Ver: 2.1.0
* yii: Yii Framework
Site:
Ver: 1.1.8
* micromvc4: MicroMVC
Site:
Ver: 4.0.0
* laravel: Laravel, A PHP Framework For Web Artisans
Site:
Ver: 2.0.2
* slim: Slim Framework
Site:
Ver: 1.5.0
* yaf: Yet Another Framework in PHP Extension
Site:
Ver: 2.1.3-beta (yaf.cache_config=1)
* FuelPHP: Simple, Flexible, Community driven Web Framework
Site:
Ver: 1.1
* ColaPHP:
Site:
Ver: 1.2-ga
# XHProf: A Hierarchical Profiler for PHP
Site:
Ver: 0.9.2
# The source code of this testing:
Source:
1. Apache Benchmark
Requests pre second (-c 100 -n 30000), the bigger is better
请求/秒(-c 200 -n 50000), 数值越大越好
2. 系统负载
压力测试一分钟内完成的负载图
越小越好(-c 100 -n 30000)
3. 内存使用率
测试hello word占用的内存,越小越好.
4. 响应时间
页面的响应时间.单位微妙
5. 调用方法的数量(Facebook XHProf)
单个hello word页面调用了多少方法,zend5620个方法,是不是太臃肿了。
6. 文件数量
打开hellow word用到included or required in 文件的数量.越小越好,zend很多,yii19个,yaf才4个,不快才怪。