加入收藏 | 设为首页 | 会员中心 | 我要投稿 东莞站长网 (https://www.0769zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 安全 > 正文

WordPress博客PHP7.1与7.2性能对比

发布时间:2021-02-23 07:30:40 所属栏目:安全 来源:网络整理
导读:由站长通过网络收集整理的代码片段。编程之家小编现在分享给大家,也给大家做个参考。 去年就已经使用 PHP7 版本了,那时就说 PHP7 比老版本快了很多很多,在今年,又分别出了 7.1 和 7.2 版本,从 wordpress 4.9.3 开始,该版本修复了 4.9

以下代码由PHP站长网 52php.cn收集自互联网现在PHP站长网小编把它分享给大家,仅供参考

去年就已经使用 PHP7 版本了,那时就说 PHP7 比老版本快了很多很多,在今年,又分别出了 7.1 和 7.2 版本,从 wordpress 4.9.3 开始,该版本修复了 4.9 以来的 34 个问题。包括外观定制器更改、小工具、可视编辑器和 php 7.2 兼容性的修复。做了一些对比后,最终决定将博客环境升级到 PHP7.2 版本。


WordPress博客PHP7.1与7.2性能对比

PHP7.1/7.2 对比图:

汇总

bench.php

bench.php + opcache

micro_bench.php

micro_bench.php + opcache

PHP7.1

1.3859

0.8133

5.6365

4.3600

PHP7.2

1.4514

0.7867

5.5840

3.7234

WordPress博客PHP7.1与7.2性能对比

压力测试:

未开启 opcache

# php7.1

Concurrency Level: 10

Time taken for tests: 8.696 seconds

Complete requests: 100

Failed requests: 0

Write errors: 0

Total transferred: 5215300 bytes

HTML transferred: 5189300 bytes

Requests per second: 11.50 [#/sec] (mean)

Time per request: 869.637 [ms] (mean)

Time per request: 86.964 [ms] (mean,across all concurrent requests)

Transfer rate: 585.65 [Kbytes/sec] received

# php7.2

Concurrency Level: 10

Time taken for tests: 8.528 seconds

Complete requests: 100

Failed requests: 0

Write errors: 0

Total transferred: 5215500 bytes

HTML transferred: 5189300 bytes

Requests per second: 11.73 [#/sec] (mean)

Time per request: 852.793 [ms] (mean)

Time per request: 85.279 [ms] (mean,across all concurrent requests)

Transfer rate: 597.24 [Kbytes/sec] received

可以看到在未开启 opcache 的情况下,性能非常糟糕,10 个并发的情况下,每个请求的响应时间已经非常长了,没有必要继续增加并发数了。


开启 opcache 之后:

汇总

7.1 Requests per second (每秒)

7.1 Time per request (ms)

7.2 Requests per second (每秒)

7.2 Time per request (ms)

c10 n100

60.63

164.939

70.05

142.762

c20 n200

66.27

301.803

70.74

282.719

c30 n300

66.50

451.121

70.89

423.2

c40 n400

67.95

588.683

70.6

566.608

WordPress博客PHP7.1与7.2性能对比


在开启 opcache 之后,相对之前未开启的情况性能简直天壤之别。相比之下 php7.2 在 wordpress 压测上,QPS 稳定在 70+ 相对 php7.1 增加不少。测试结果和配置参数以及服务器配置有关,仅供对比 php7.1 与 7.2 的性能。

以上内容由PHP站长网【52php.cn】收集整理供大家参考研究如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。

(编辑:东莞站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!