Home >Backend Development >PHP Tutorial >PHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP Tutorial

PHP7 RC7 Release Comparison of PHP5.6 Quick Sort 20000 Data Performance Experience and New Syntax Tryout_PHP Tutorial

WBOY
WBOYOriginal
2016-07-12 09:04:03840browse

PHP7 RC7 Release compared to PHP5.6 quick sort 20000 data performance experience and new syntax tryout

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.

  • Improved performance: PHP 7 is up to twice as fast as PHP 5.6 Consistent 64-bit support 64-bit consistency support Many fatal errors are now Exceptions Remove of old and unsupported SAPIs and extensions Removed old unsupported SAPIS and some extensions The null coalescing operator (??) Combined comparison operator () Return Type Declarations are displayed the same as C language, etc. Return value type Scalar Type Declarations Scalar type definition Anonymous Classes Anonymous classes! Out of curiosity, I installed PHP5.5 and PHP7 RC7 Release at the same time to experience it, so I experienced the performance improvement and new syntax of PHP7 respectively. As for how to install and configure PHP7 I believe I don’t need to say anything else, no more nonsense.
    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 How much has the performance of PHP7 improved compared to PHP5.6? You will know by testing it with a simple and silly code. Here I will use the 5.5 version of PHP to compare. There is only 5.5 on the computer and I am too lazy to install PHP5.6.
    As shown below php7 and php5.5: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 Tutorial

    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>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn