Home >Backend Development >PHP Tutorial >PHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP Tutorial
Recently, Zend’s PHP7 has been in the final bug fixing stage, and RC7 has been updated. According to Zend’s official statement, the performance of PHP7 is about 2 times higher than that of the PHP5 series version, and some new syntax has been added. Some factors affecting performance of PHP5 have been removed, and the following Features have been mainly added.
http:PHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP TutorialPHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP Tutorialphp.netPHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP Tutorial php7 RC7 Release official address
https:PHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP TutorialPHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP Tutorialwiki.php.netPHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP TutorialrfcPHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP Tutorialscalar_type_hints_v5 PHP7 wiki
1. Performance comparison between PHP7 and PHP5.5
As shown below php7 and php5.5:
1.1 Here I use a small piece of silly code to test PHP:
<!--?php
function microtime_float()
{
list($usec, $sec) = explode( , microtime());
return ((float)$usec + (float)$sec);
}
define('ARRAY_SIZE',20000);
function QuickSort($arr,$low,$high)
{
if($low-->$high)
return ;
$begin=$low;
$end=$high ;
$key=$arr[$begin];
while($begin=$key)
--$end ;
$arr[$begin]=$arr[$end];
while($begin<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialpre>
<h2><strong>1.2 Test results<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialstrong><php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialh2>
After running 20,000 random data under PHP7 and PHP5.5 respectively, the result after the quick sort algorithm is that PHP7 is 12 times that of PHP5.5!!!! It seems that PHP7 is starting to take off! <br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
The following are the speeds of PHP7 RC7 and PHP5 running the above quick sort 20000 data algorithm. <br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<img alt="PHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP Tutorial" src="http:PHP7%20RC7%20Release%20Comparison%20of%20PHP5.6%20Quick%20Sort%2020000%20Data%20Performance%20Experience%20and%20New%20Syntax%20Tryout_PHP%20TutorialPHP7%20RC7%20Release%20Comparison%20of%20PHP5.6%20Quick%20Sort%2020000%20Data%20Performance%20Experience%20and%20New%20Syntax%20Tryout_PHP%20Tutorialwww.bkjia.comPHP7%20RC7%20Release%20Comparison%20of%20PHP5.6%20Quick%20Sort%2020000%20Data%20Performance%20Experience%20and%20New%20Syntax%20Tryout_PHP%20TutorialuploadsPHP7%20RC7%20Release%20Comparison%20of%20PHP5.6%20Quick%20Sort%2020000%20Data%20Performance%20Experience%20and%20New%20Syntax%20Tryout_PHP%20TutorialallimgPHP7%20RC7%20Release%20Comparison%20of%20PHP5.6%20Quick%20Sort%2020000%20Data%20Performance%20Experience%20and%20New%20Syntax%20Tryout_PHP%20Tutorial151129PHP7%20RC7%20Release%20Comparison%20of%20PHP5.6%20Quick%20Sort%2020000%20Data%20Performance%20Experience%20and%20New%20Syntax%20Tryout_PHP%20Tutorial041F35C7-2.jpg" php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial><img alt="PHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP Tutorial" src="http:PHP7%20RC7%20Release%20Comparison%20of%20PHP5.6%20Quick%20Sort%2020000%20Data%20Performance%20Experience%20and%20New%20Syntax%20Tryout_PHP%20TutorialPHP7%20RC7%20Release%20Comparison%20of%20PHP5.6%20Quick%20Sort%2020000%20Data%20Performance%20Experience%20and%20New%20Syntax%20Tryout_PHP%20Tutorialwww.bkjia.comPHP7%20RC7%20Release%20Comparison%20of%20PHP5.6%20Quick%20Sort%2020000%20Data%20Performance%20Experience%20and%20New%20Syntax%20Tryout_PHP%20TutorialuploadsPHP7%20RC7%20Release%20Comparison%20of%20PHP5.6%20Quick%20Sort%2020000%20Data%20Performance%20Experience%20and%20New%20Syntax%20Tryout_PHP%20TutorialallimgPHP7%20RC7%20Release%20Comparison%20of%20PHP5.6%20Quick%20Sort%2020000%20Data%20Performance%20Experience%20and%20New%20Syntax%20Tryout_PHP%20Tutorial151129PHP7%20RC7%20Release%20Comparison%20of%20PHP5.6%20Quick%20Sort%2020000%20Data%20Performance%20Experience%20and%20New%20Syntax%20Tryout_PHP%20Tutorial041F3KM-3.jpg" php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial><br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<h1>2. PHP7 new syntax experience<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialh1>
<h2>2.1, Scalar type and strong type<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialh2>
<code>PHP7新增四个标量类型 int<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialcode>, <code>float<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialcode>, <code>string<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialcode> <code>bool, 首先要使用强类型 必须在文件中加入指令<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialcode><php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialli>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<li class="level1"><code>declare(strict_types=1)该指令必须是第一个指令而且只有一种用法 <php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialcode>The so-called concept of strict typing and strong typing is that we have to abandon the concept of type before PHP5.6, because we know that PHP itself is a typed language. Because of this, type conversion and type checking lead to the PHP language The extremely low performance of php7 also proves this point, for example, the following code
<pre class="code">
<!--?php
declare(strict_types=1);
function GetInt():int{
return 1.0;
}
echo GetInt();
?--><php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialpre>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
If you change the above code to return 1;, it can run normally, otherwise an error will be reported. This is the strong type constraint of PHP7. In this mode, the if type is completely abandoned.
<pre class="code">
<!--?php
declare(strict_types=1);
function GetInt():int{
return 1;
}
echo GetInt();
?--><php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialpre>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<h2>2.2 Strong type parameters<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialh2>
<pre class="code">
<!--?php
declare(strict_types=1);
function add(int $a,int $b):int{
return $a+$b;
}
echo add(1,2);
?--><php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialpre>
<pre class="code">
<!--?php
declare(strict_types=1);
function add(int $a,int $b):int{
return $a+$b;
}
var_dump(add(1,2));
?--><php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialpre>
The result of var_dump is int(3)<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<h2>2.3 Return type conflict<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialh2>
If the return value type is different from the strong type constraint, an exception will be thrown.
<pre class="code">
<!--?php
declare(strict_types=1);
function foobar(float $abc): int {
return ceil($abc + 1);
}
try{
foobar(1.22);
}catch(Exception $ex){
echo $ex--->getMessage();
}
?><php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialpre>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
OK, I won’t write about Scalar Type one by one <br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
For more introduction, please refer to: https:PHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP TutorialPHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP Tutorialwiki.php.netPHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP TutorialrfcPHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP Tutorialscalar_type_hints_v5#php_rfcscalar_type_declarations<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<h2><strong>2.4, About PHP’s Anonymous Class<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialstrong><php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialh2>
<strong>Simple anonymous class inheritance<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialstrong>
<pre class="code">
<!--?php
declare(strict_types=1);
class Foo {public function M1(){echo 'hello,world!';}}
$child = new class extends Foo { public function M2(){echo 'hello,world!';return $this;}};
$child--->M2()->M1();
?><php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialpre>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<strong>Simple anonymous class instantiation<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialstrong>
<pre class="code">
<!--?php
declare(strict_types=1);
var_dump(new class(5) {
public function __construct($i) {
$this--->i = $i;
}
});
?><php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialpre>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<br php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorial>
<p> <php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialp>
<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialli>
<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialul> <php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialp>
<p align="left"></p><div style="display:none;"><span id="url" itemprop="url">http:PHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP TutorialPHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP Tutorialwww.bkjia.comPHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP TutorialPHPjcPHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP Tutorial1075799.html<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialspan><span id="indexUrl" itemprop="indexUrl">www.bkjia.com<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialspan><span id="isOriginal" itemprop="isOriginal">true<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialspan><span id="isBasedOnUrl" itemprop="isBasedOnUrl">http: PHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP TutorialPHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP Tutorialwww.bkjia.comPHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP TutorialPHPjcPHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP Tutorial1075799.html<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialspan><span id="genre" itemprop="genre">TechArticle<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialspan><span id="description" itemprop="description">PHP7 RC7 Release compared to PHP5.6 quick sort 20000 data performance experience and new syntax early adopters Recently Zend’s PHP7 has been at the bottom In the BUG repair stage, RC7 has been updated. For Zend official...<php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialspan><php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialdiv><php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialp><php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialdiv>
<div class="art_confoot"><php7 rc7 release comparison of php5.6 quick sort data performance experience and new syntax tryout_php tutorialdiv></php7></div></php7></php7></php7></php7></span></php7></span></php7></span></php7></span></php7></span></php7></span></div></php7></php7></php7></php7></p></php7>