首先展示一下其他主要框架的测试:
https://github.com/kenjis/php-framework-benchmark
框架地址:
https://github.com/chopins/toknot
测试用例是仓库中app/admin应用
我的测试环境:
与上面用 apache web 服务器不同,我用的是 nginx
php 版本: 5.6.0
php 扩展情况:
[PHP Modules]
Core
date
ereg
mysqli
mysqlnd
pcre
PDO
pdo_mysql
Reflection
session
SPL
standard
Zend OPcache
[Zend Modules]
Zend OPcache
php-fpm 配置:
pm.max_children = 8
pm.start_servers = 4
pm.max_spare_servers = 4
pm.min_spare_servers = 2
测试命令:
ab -n 10000 -c 4 http://127.0.0.1/account/signup
业务:
测试结果:
Server Software: nginx/1.10.2
Server Hostname: 127.0.0.1
Server Port: 80
Document Path: /account/signup
Document Length: 36 bytes
Concurrency Level: 4
Time taken for tests: 11.643 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 2600000 bytes
HTML transferred: 360000 bytes
Requests per second: 858.89 [#/sec] (mean)
Time per request: 4.657 [ms] (mean)
Time per request: 1.164 [ms] (mean, across all concurrent requests)
Transfer rate: 218.08 [Kbytes/sec] received
858.89
RPS 比 CI-3.0 的 753.09
略高,比 fatfree3.5 的 965.16
略低
内存占用:
PHP 7.0 测试情况
opcache 版本:
Concurrency Level: 8
Time taken for tests: 7.578 seconds
Complete requests: 10000
Failed requests: 7
(Connect: 0, Receive: 0, Length: 7, Exceptions: 0)
Total transferred: 102427973 bytes
HTML transferred: 100177973 bytes
Requests per second: 1319.60 [#/sec] (mean)
Time per request: 6.062 [ms] (mean)
Time per request: 0.758 [ms] (mean, across all concurrent requests)
Transfer rate: 13199.60 [Kbytes/sec] received
无 opcache 版本:
Concurrency Level: 100
Time taken for tests: 190.636 seconds
Complete requests: 50000
Failed requests: 41
(Connect: 0, Receive: 0, Length: 41, Exceptions: 0)
Total transferred: 512146699 bytes
HTML transferred: 500896699 bytes
Requests per second: 262.28 [#/sec] (mean)
Time per request: 381.271 [ms] (mean)
Time per request: 3.813 [ms] (mean, across all concurrent requests)
Transfer rate: 2623.55 [Kbytes/sec] received
有无 opcache 相差好大
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.