WordPress サーバーで PHP 7 と古いバージョンを比較するこのベンチマークを再現しようとしました: http://talks.php.net/oz15#/wpbench
私の構成はほぼ同じで、サーバーには i7、SSD、16GB RAM、debian があります。サーバーソフトウェアはnginxです。驚いたことに、私の結果は上記のリンクとは大きく異なります。
私のテストでは、Siege ( https://www.joedog.org/siege-home/ ) は以下を出力します:
PHP 7.0.0RC1 の場合:
siege -c100 -r100 http://10.22.255.133/wordpress/
** SIEGE 3.0.8
** Preparing 100 concurrent users for battle.
The server is now under siege.. done.
Transactions: 10000 hits
Availability: 100.00 %
Elapsed time: 131.61 secs
Data transferred: 95.77 MB
Response time: 0.75 secs
Transaction rate: 75.98 trans/sec
Throughput: 0.73 MB/sec
Concurrency: 56.98
Successful transactions: 10000
Failed transactions: 0
Longest transaction: 1.01
Shortest transaction: 0.04
PHP 5.6.12 の場合:
siege -c100 -r100 http://10.22.255.133/wordpress/
** SIEGE 3.0.8
** Preparing 100 concurrent users for battle.
The server is now under siege.. done.
Transactions: 10000 hits
Availability: 100.00 %
Elapsed time: 63.41 secs
Data transferred: 95.77 MB
Response time: 0.03 secs
Transaction rate: 157.70 trans/sec
Throughput: 1.51 MB/sec
Concurrency: 4.45
Successful transactions: 10000
Failed transactions: 0
Longest transaction: 0.63
Shortest transaction: 0.01
トランザクション レートを見ると、PHP 5 は PHP 7 の約 2 倍高速であることがわかります。信じられません。
もう 1 つの興味深い事実は、このベンチマーク ( http://www.php-benchmark-script.com/ ) を実行すると、PHP 7 が PHP 5 よりも約 3 倍高速になることです (もちろん、私がテストした同じサーバー上で)ワードプレス)。測定結果は次のとおりです。
- PHP 7.0.0RC1 | PHP 5.5.28
- 数学: 0.201 | 0.683
- 文字列操作: 0.271 | 0.77
- ループ: 0.166 | 0.486
- それ以外の場合: 0.12 | 0.295
役立つ場合に備えて、両方の phpinfo() ファイルをアップロードしました。
- PHP バージョン 7.0.0RC1: http://simsso.de/downloads/stackoverflow/php7.html
- PHP バージョン 5.6.12-0+deb8u1: http://simsso.de/downloads/stackoverflow/php5.html
私のWordpressでのテストで、なぜPHP 7がそれほど遅くなったのか分かりますか?
opcacheを有効にすると、 PHP 7 は実際には PHP 5 の 2 倍の速度になります。ヒントをくれた Mjh に感謝します!
ランダムに満たされた WordPress サーバーで次の測定を行いました。
Siege は、 PHP 7.0.0RC1に対して以下を出力するようになりました。
Transactions: 10000 hits
Availability: 100.00 %
Elapsed time: 62.14 secs
Data transferred: 604.20 MB
Response time: 0.02 secs
Transaction rate: 160.93 trans/sec
Throughput: 9.72 MB/sec
Concurrency: 3.77
Successful transactions: 10000
Failed transactions: 0
Longest transaction: 0.41
Shortest transaction: 0.01
そしてPHP 5.6.12:
siege -c100 -r100 http://10.22.255.133/wordpress/
** SIEGE 3.0.8
** Preparing 100 concurrent users for battle.
The server is now under siege.. done.
Transactions: 10000 hits
Availability: 100.00 %
Elapsed time: 119.98 secs
Data transferred: 604.20 MB
Response time: 0.60 secs
Transaction rate: 83.35 trans/sec
Throughput: 5.04 MB/sec
Concurrency: 49.86
Successful transactions: 10000
Failed transactions: 0
Longest transaction: 4.06
Shortest transaction: 0.04