PHP7 与 PHP5 性能对比

环境

KVM VPS 1G 1 cores/ CentOS release 6.6 (Final) / Nginx/1.2.9 + PHP-FPM

都开启 opcache 运行 WordPress 4.3.1,安装后默认主题、默认插件、无优化无修改、自带测试的文章

另外附上 PHP7 的 WordPress http://php7.baozy.com/

 

PHP 5.6.15 vs PHP 7.0.0

ab -c 100 -n 1000 测试结果

PHP 5.6

Requests per second: 12.74 [#/sec] (mean)
Time per request: 7847.237 [ms] (mean)
Time per request: 78.472 [ms] (mean, across all concurrent requests)

PHP7 

Requests per second: 32.54 [#/sec] (mean)
Time per request: 3073.497 [ms] (mean)
Time per request: 30.735 [ms] (mean, across all concurrent requests)

 

详细如下

[xx@bird ~] ab -n 1000 -c 100 http://php56/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarkingphp56 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: nginx/1.2.9
Server Hostname: php56
Server Port: 80

Document Path: /
Document Length: 8854 bytes

Concurrency Level: 100
Time taken for tests: 78.472 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 9086000 bytes
HTML transferred: 8854000 bytes
Requests per second: 12.74 [#/sec] (mean)
Time per request: 7847.237 [ms] (mean)
Time per request: 78.472 [ms] (mean, across all concurrent requests)
Transfer rate: 113.07 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 6.1 0 24
Processing: 234 7447 1342.3 7763 8656
Waiting: 213 7426 1342.8 7743 8633
Total: 241 7449 1337.8 7763 8656

Percentage of the requests served within a certain time (ms)
50% 7763
66% 7903
75% 7975
80% 8009
90% 8174
95% 8376
98% 8488
99% 8550
100% 8656 (longest request)

 

[xx@bird ~] ./ab -n 1000 -c 100 http://php7/
-bash: ./ab: 没有那个文件或目录
[root@bird ~]# ab -n 1000 -c 100 http://php7/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking php7 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: nginx/1.2.9
Server Hostname: php7
Server Port: 80

Document Path: /
Document Length: 8823 bytes

Concurrency Level: 100
Time taken for tests: 30.735 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 9053000 bytes
HTML transferred: 8823000 bytes
Requests per second: 32.54 [#/sec] (mean)
Time per request: 3073.497 [ms] (mean)
Time per request: 30.735 [ms] (mean, across all concurrent requests)
Transfer rate: 287.65 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 3 7.8 0 28
Processing: 117 2931 592.8 3003 3817
Waiting: 99 2924 592.7 2998 3806
Total: 129 2934 586.9 3003 3817

Percentage of the requests served within a certain time (ms)
50% 3003
66% 3146
75% 3249
80% 3282
90% 3438
95% 3607
98% 3721
99% 3772
100% 3817 (longest request)

 

 

 

 

 

 

分类 技术流

4 条评论

发表评论