- PHP7性能基准测试,与PHP5性能的对比
对比PHP版本选择PHP7.3.11 与 PHP5.6.40, 分别运行php5.6.4源码包Zend目录中的bench.php与micro_bench.php
- bench.php
php7.3.11耗时0.435, php5.6.40耗时1.285
14:15 debian@debian:Zend $/usr/local/php7.3.11/bin/php bench.php
simple 0.019
simplecall 0.006
simpleucall 0.015
simpleudcall 0.015
mandel 0.093
mandel2 0.089
ackermann(7) 0.014
ary(50000) 0.002
ary2(50000) 0.002
ary3(2000) 0.031
fibo(30) 0.051
hash1(50000) 0.008
hash2(500) 0.006
heapsort(20000) 0.020
matrix(20) 0.017
nestedloop(12) 0.033
sieve(30) 0.011
strcat(200000) 0.003
------------------------
Total 0.435
14:15 debian@debian:Zend $/usr/local/php5.6.40/bin/php bench.php
simple 0.045
simplecall 0.069
simpleucall 0.069
simpleudcall 0.071
mandel 0.118
mandel2 0.165
ackermann(7) 0.062
ary(50000) 0.019
ary2(50000) 0.013
ary3(2000) 0.097
fibo(30) 0.237
hash1(50000) 0.024
hash2(500) 0.020
heapsort(20000) 0.057
matrix(20) 0.059
nestedloop(12) 0.080
sieve(30) 0.076
strcat(200000) 0.007
------------------------
Total 1.285
- mirco_bench.php
php7.3.11耗时2.081, php5.6.40耗时6.213
14:19 debian@debian:Zend $php micro_bench.php
empty_loop 0.021
func() 0.066 0.045
undef_func() 0.073 0.052
int_func() 0.044 0.023
$x = self::$x 0.063 0.042
self::$x = 0 0.059 0.038
isset(self::$x) 0.065 0.044
empty(self::$x) 0.064 0.043
$x = Foo::$x 0.048 0.027
Foo::$x = 0 0.044 0.023
isset(Foo::$x) 0.044 0.023
empty(Foo::$x) 0.048 0.027
self::f() 0.082 0.061
Foo::f() 0.071 0.050
$x = $this->x 0.041 0.020
$this->x = 0 0.035 0.014
$this->x += 2 0.059 0.038
++$this->x 0.049 0.028
--$this->x 0.049 0.028
$this->x++ 0.054 0.033
$this->x-- 0.058 0.037
isset($this->x) 0.061 0.040
empty($this->x) 0.066 0.045
$this->f() 0.068 0.047
$x = Foo::TEST 0.065 0.044
new Foo() 0.170 0.149
$x = TEST 0.035 0.014
$x = $_GET 0.064 0.043
$x = $GLOBALS['v'] 0.087 0.066
$x = $hash['v'] 0.071 0.050
$x = $str[0] 0.053 0.032
$x = $a ?: null 0.050 0.029
$x = $f ?: tmp 0.055 0.034
$x = $f ? $f : $a 0.047 0.026
$x = $f ? $f : tmp 0.050 0.029
------------------------
Total 2.081
14:19 debian@debian:Zend $/usr/local/php5.6.40/bin/php micro_bench.php
empty_loop 0.076
func() 0.242 0.166
undef_func() 0.250 0.174
int_func() 0.200 0.123
$x = self::$x 0.157 0.081
self::$x = 0 0.153 0.077
isset(self::$x) 0.146 0.070
empty(self::$x) 0.177 0.101
$x = Foo::$x 0.139 0.062
Foo::$x = 0 0.144 0.068
isset(Foo::$x) 0.132 0.056
empty(Foo::$x) 0.133 0.057
self::f() 0.268 0.192
Foo::f() 0.245 0.169
$x = $this->x 0.141 0.065
$this->x = 0 0.198 0.122
$this->x += 2 0.168 0.092
++$this->x 0.165 0.089
--$this->x 0.129 0.053
$this->x++ 0.167 0.091
$this->x-- 0.159 0.082
isset($this->x) 0.142 0.066
empty($this->x) 0.150 0.074
$this->f() 0.265 0.189
$x = Foo::TEST 0.138 0.061
new Foo() 0.409 0.333
$x = TEST 0.108 0.031
$x = $_GET 0.144 0.067
$x = $GLOBALS['v'] 0.195 0.119
$x = $hash['v'] 0.156 0.079
$x = $str[0] 0.205 0.128
$x = $a ?: null 0.132 0.056
$x = $f ?: tmp 0.208 0.132
$x = $f ? $f : $a 0.162 0.086
$x = $f ? $f : tmp 0.208 0.132
------------------------
Total 6.213