我試圖重現這個基準,這與舊版本的WordPress的服務器上比較PHP 7:http://talks.php.net/oz15#/wpbenchPHP 7性能
我的配置是幾乎相同的,服務器有一個i7處理器,SSD,16GB RAM和Debian 。服務器軟件是nginx。令人驚訝的是,我的成果與我上面鏈接的很不相同。
在我的測試圍困(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快兩倍。我不能相信。
另一個有趣的事實是,運行此基準(http://www.php-benchmark-script.com/)導致PHP 7比PHP 5快3倍(當然,在我也測試過Wordpress的同一臺服務器上)。測量結果如下:
- PHP 7.0.0RC1 | PHP 5.5.28
- 數學: 0.201 | 0.683
- 字符串操作: 0.271 | 0.77
- 循環: 0.166 | 0.486
- If Else: 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
你知道爲什麼PHP 7在Wordpress測試中速度慢得多嗎?
隨着opcache啓用 PHP 7實際上是快兩倍,PHP 5感謝MJH您提示!
我對隨機填充的WordPress服務器進行了以下測量。
攻城現在輸出以下爲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
您是否關閉了測試的會話支持?另外,你是否在安裝了nginx和php-fpm的計算機上運行'siege'? – Mjh
感謝您的回覆!會話支持被禁用,Siege正在本地網絡中的另一臺機器上運行。我也確保網絡不是一個限制因素。 –
php-fpm配置對於兩個php版本都是一樣的嗎?此外,似乎opcache沒有啓用您的PHP 7,而它是爲PHP 5.這一點可以相當於巨大的差異。 – Mjh