Let's take a look at the PHP 7 official version of the algorithm and the performance of WordPress application on it.
PHP7 installation, really very backward-compatible, download, decompression, the previous configuration command used, all the way to go down, no Shong sense. In order not to affect the operation of the existing environment, all specialize in opening up the directory.
The configuration parameters are as follows:
--PREFIX=/USR/LOCAL/PHP7--with-config-file-path=/usr/local/php7/etc--enable-fpm--with-fpm-user=www-- With-fpm-group=www--with-mysqli--with-pdo-mysql--with-iconv-dir--with-freetype-dir--with-jpeg-dir-- With-png-dir--with-zlib--with-libxml-dir=/usr--enable-xml--disable-rpath--enable-bcmath-- Enable-sysvsem--enable-inline-optimization--with-curl--enable-mbregex--enable-mbstring--with-mcrypt-- Enable-ftp--with-gd--enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets--with-xmlrpc --enable-zip--enable-soap--without-pear--with-gettext--disable-fileinfo--enable-maintainer-zts
GCC version
According to Bird's advice, use a new compiler, recommend GCC more than 4.8, because only gcc more than 4.8 PHP will open the Global Register for Opline and execute_data support, this will bring about 5% performance improvement. So the GCC version selected for this experiment is GCC versions 4.8.2 20131212 (Red Hat 4.8.2-8) (GCC).
After installation, do the soft link:
Ln-s/usr/local/php7/bin/php/usr/bin/php7
ln-s/usr/local/php7/bin/php-config/usr/bin/php7-config
ln-s/ Usr/local/php7/bin/phpize/usr/bin/php7ize
ln-s/usr/local/php7/sbin/php-fpm/usr/sbin/php7-fpm
Php7-v saw our familiar hints:
[Root@localhost test]# php7-v
PHP 7.0.0 (CLI) (Built:dec 2 2015 19:19:14) (ZTS)
Copyright (c) 1997-2015 the PH P Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
The first thing to do is performance evaluation, evaluation models, the capital online cloud host, 4 core CPU Intel (R) Xeon (r) CPU e5-2680 0 @ 2.70GHz, memory 4G, operating system Centos 6.5.
Write three sections of the program randomly:
The first paragraph generates an array of 600,000 elements to determine whether the key exists by looking up the key.
<?php
$a = array ();
For ($i =0 $i <600000; $i + +) {
$a [$i] = $i;
}
foreach ($a as $i)
{
array_key_exists ($i, $a);
}
First is the PHP 5.3.17 version .
[Root@localhost test]# time PHP search_by_key.php real
0m0.389s
user 0m0.337s
sys 0m0.051s
[Root@localhost test]# time PHP search_by_key.php real
0m0.378s
user 0m0.308s
sys 0m0.062s
[Root@localhost test]# time PHP search_by_key.php real
0m0.378s
user 0m0.317s
sys 0m0.061s
followed by the PHP7 version .
[Root@localhost php7]# time PHP7 search_by_key.php real
0m0.082s
user 0m0.066s
sys 0m0.014s
[ Root@localhost php7]# time PHP7 search_by_key.php real
0m0.080s
user 0m0.058s
sys 0m0.021s
[ Root@localhost php7]# time PHP7 search_by_key.php real
0m0.080s
user 0m0.053s
sys 0m0.026s '
This just shot, on the well-deserved reputation, response time in PHP7 run into the original 1/4. Real cow!
Then I'm going to have to try the two, the second, or the above, but because it's slow, it turns into an array of 60,000 elements, looking for values.
The code is as follows:
PHP Code:
<?php
$a = array ();
For ($i =0 $i <600000; $i + +) {
$a [$i] = $i;
}
foreach ($a as $i)
{
array_key_exists ($i, $a);
}
[Root@localhost test]# time PHP search_by_val.php real
0m24.296s
user 0m24.184s
sys 0m0.025s
[root@localhost test]# time PHP search_by_val.php real
0m25.523s
user 0m25.317s
sys 0m0.026s
[root@localhost test]# time PHP search_by_val.php real
0m26.026s
user 0m25.478s
sys 0m0.092s
Waiting time, always feel very long, three test, spent 75 seconds more. Below, PHP 7 is on the scene.
[Root@localhost php7]# time PHP7 search_by_val.php real
0m3.362s
user 0m3.323s
sys 0m0.007s
[ Root@localhost php7]# time PHP7 search_by_val.php real
0m3.266s
user 0m3.251s
sys 0m0.004s
[ Root@localhost php7]# time PHP7 search_by_val.php real
0m3.290s
user 0m3.275s
sys 0m0.006s
Do you have! The speed was nearly 7 times times higher.
The author's excited mood is difficult to say, conveniently and the whole of a more efficient prime algorithm. Figure out the number of prime numbers within 2000000, this time we PHP7 start first.
[Root@localhost php7]# time PHP7 prime_v3.php 2000000 real
0m1.151s
user 0m1.129s
sys 0m0.010s
[root@localhost php7]# time PHP7 prime_v3.php 2000000 real
0m1.141s
user 0m1.123s
sys 0m0.011s
[root@localhost php7]# time PHP7 prime_v3.php 2000000 real
0m1.145s
user 0m1.128s
sys 0m0.010s '
Speed stabilized at 1.2 S
And PHP 5.3, this time is smaller than the last one, but PHP7 speed is also its 3 times times to 4 times times between.
[Root@localhost test]# time PHP prime_v3.php 2000000
Prime # Count under 2000000 is:148933 real
0m4.425s
user 0m4.380s
sys 0m0.023s
[root@localhost test]# time PHP prime_v3.php 2000000 prime number
count Under 2000000 is:148933 real
0m4.457s
user 0m4.414s
sys 0m0.032s
[root@localhost test]# time PHP prime_v3.php 2000000
Prime number count under 2000000 is:148933 real
0m4.464s
user 0m4.399s
sys 0m0.046s
This prime number algorithm is as follows, using the filtering method. It is relatively fast to calculate the prime number algorithm.
<?php
* * To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* *
$num = $argv [1];
$ret = Array (2);
$flag = false;
for ($i =3; $i <= $num; $i +=2)
{
$flag = false;
$sqrt = sqrt ($i);
foreach ($ret as $prime)
{
if ($i% $prime = 0)
{
$flag = true;
break;
if ($prime > $sqrt)
{break
;
}
}
if (! $flag)
{
$ret [] = $i;
}
}
Echo (count ($ret)). \ n ";
At this point, we can basically explain the problem. The code, which does not use a complex library of functions, nor a large number of networks and IO, has been optimized for at least 3 times times the performance. This is a historic advance. In our past performance evaluation, language level performance is often ignored, why so, for example, in the Xhprof, there is a special option, xhprof_flags_no_builtins, for the built-in functions or internal functions do not analyze, such as arrays, Functions such as dates. Because we often miss this piece of ascension space, of course, the general people can not be promoted in this block, so have the HHVM, also inspired today's PHP 7.
A round of testing, inspired by the author of Php 7 more understanding of the interest, want to see the expansion and some common framework support how, conveniently did the following two Tests.
Remember in the ALPHA1 version of the time, ONEAPM can not support, this can not do? I get Oneapm_php_agent_1.0.0.18.tar version, smooth installation.
Successfully identified the installation path for PHP 7.
The installation was successful.
For the expansion, I do not have the confidence to further the test, the following two commonly used Dongdong, one is WordPress, although the site was harmonious, but what the earth people know it. Another is thinkphp, this is the most widely used PHP development framework, is absolutely first, not one. I am also a fan of TP.
Is it better to boast about the two software? Or the praise of the PHP 7 compatibility done well, I do not know, anyway small series see the initial normal.
Wordpress backstage, in PHP 7 as a FastCGI back-end, running normally.
thinkphp the latest version of 3.2.3 is working under PHP 7.
Finally we do a stress test, two WordPress, one is basically empty just installed version, one is the release of a number of articles, we are testing the home page. Test under PHP5.5 and PHP7 respectively, and both turn on and off Zend Opcache to see if there is a noticeable change in response performance.
1, PHP 5.5.26 no Zend opcache an article version, 20 concurrent
2, PHP 5.5.26 no Zend opcache an article version, 10 concurrent
3, PHP 5.5.26 no Zend Opcache no article version, 20 concurrent
4, PHP 5.5.26 no Zend Opcache no article version, 10 concurrent
Visible concurrency does not affect the total time, there is no article compared to the total length of 6S slow, on average 20% slow.
Below we open the PHP 5.5.26 Zend Opcache.
1, PHP 5.5.26 has Zend Opcache an article version, 20 concurrent
2, PHP 5.5.26 has Zend Opcache an article version, 10 concurrent
3, PHP 5.5.26 has Zend Opcache no article version, 20 concurrent
4, PHP 5.5.26 has Zend Opcache no article version, 10 concurrent
Visible, whether to open Zend Opcache, the effect on performance is very obvious. On the An article version has twice times above the promotion, to no article version has 4 times times above the promotion.
Let's test the PHP7, the first time there is no Zend Opcache version.
1, PHP 7 without Zend Opcache an article version, 20 concurrent
2, PHP 7 without Zend Opcache an article version, 10 concurrent
From the above data can be seen in the PHP7 contrast PHP5.5.26 has about 30% performance improvement, and then look at no article version.
3, PHP7 no Zend Opcache no article version, 20 concurrent
4, PHP 7 no Zend Opcache no article version, 10 concurrent
No article version of the contrast PHP5.5.26 has about 60% of the promotion. Now let's take a look at the version of Zend Opcache that opens PHP7.
Note that the PHP7 Zend Opcache is different from PHP5 and does not require a special installation extension, just add the following three-line configuration to the php.ini.
zend_extension=opcache.so
Opcache.enable=1
Opcache.enable_cli=1
1, PHP 7 has Zend Opcache an article version, 20 concurrent
2, PHP 7 has Zend Opcache an article version, 10 concurrent
3, PHP 7 has Zend Opcache no article version, 20 concurrent
4, PHP 7 has Zend Opcache no article version, 10 concurrent
Too invincible, open Zend Opcache, has more than 5 times times performance promotion, and contrast also open Zend Opcache 5.5 26, also at least 3 times times higher performance. It can be said that Zend Opcache is critical to the performance of high concurrency.
PHP7 performance evaluation is here, since the launch of the PHP7 Alpha version in June, we are delighted to wait for the PHP7 official release. Again the test proves that PHP7, worthy of your own, ONEAPM for PHP is able to drill down into all PHP applications to perform application management and monitoring, including the visibility of code-level performance issues, rapid identification and traceability of performance bottlenecks, real user experience monitoring, server monitoring, and End-to-end application performance management. and opened the Zend Opcache PHP7 and ONEAPM, it is worth your warm to have.