在 Gentoo 下,使用 elselect 來切換不同版本的 PHP,下面的指令為切換成 PHP 7.0
# eselect php set cli php7.0
使用 PHP 內附的 httpd server
$ php -S 127.0.0.1:8080
使用 siege 來測試效能
$ siege -c 10 -r 10 -u http://127.0.0.1:8080/ntu-ocw/index.php/ocw/cou/104S113
網頁程式,是自己管的開放式課程 (NTU OCW),使用 Laravel 5.1。
三者比較的結果,PHP 7.0 > PHP 7.1 > PHP 5.6,和網上看到的結果一致。
看起來有夠少的,可是測一下 index.html,卻也只有 Transaction rate: 14.27 trans/sec,實在是不可思議啊,是我不會用 siege?
補充說明
本文看看就好,我必須承認沒有什麼參考性。此網站使用 Laravel framework,受到 session 的影響很大,假如不啟動 session,是可以讓效能提升很多的。PHP 7.1.1 的結果
Transactions: 100 hitsAvailability: 100.00 %
Elapsed time: 10.77 secs
Data transferred: 5.63 MB
Response time: 0.39 secs
Transaction rate: 9.29 trans/sec
Throughput: 0.52 MB/sec
Concurrency: 3.63
Successful transactions: 100
Failed transactions: 0
Longest transaction: 0.76
Shortest transaction: 0.09
PHP 7.0.15 的結果
Transactions: 100 hitsAvailability: 100.00 %
Elapsed time: 9.83 secs
Data transferred: 5.63 MB
Response time: 0.35 secs
Transaction rate: 10.17 trans/sec
Throughput: 0.57 MB/sec
Concurrency: 3.54
Successful transactions: 100
Failed transactions: 0
Longest transaction: 0.61
Shortest transaction: 0.08
PHP 5.6.29 的結果
Transactions: 100 hitsAvailability: 100.00 %
Elapsed time: 11.37 secs
Data transferred: 5.63 MB
Response time: 0.42 secs
Transaction rate: 8.80 trans/sec
Throughput: 0.50 MB/sec
Concurrency: 3.68
Successful transactions: 100
Failed transactions: 0
Longest transaction: 0.78
Shortest transaction: 0.10
正式網站 Apache 2.2.15 + PHP 5.4.42
Transactions: 100 hitsAvailability: 100.00 %
Elapsed time: 8.15 secs
Data transferred: 5.74 MB
Response time: 0.22 secs
Transaction rate: 12.27 trans/sec
Throughput: 0.70 MB/sec
Concurrency: 2.69
Successful transactions: 100
Failed transactions: 0
Longest transaction: 0.40
Shortest transaction: 0.15
nginx/1.10.2 + PHP/7.0.14
Transactions: 100 hitsAvailability: 100.00 %
Elapsed time: 8.62 secs
Data transferred: 5.95 MB
Response time: 0.18 secs
Transaction rate: 11.60 trans/sec
Throughput: 0.69 MB/sec
Concurrency: 2.05
Successful transactions: 100
Failed transactions: 0
Longest transaction: 0.30
Shortest transaction: 0.13
沒有留言:
張貼留言