PHP7RC7Release compared with PHP5.6 quick sorting 20000 data performance experience and new syntax. PHP7RC7Release comparison PHP5.6 fast sorting 20000 data performance experience and new syntax early adopters Zend PHP7 is in the final BUG fixing stage, and RC7 has been updated, comparison between Zend official PHP7 RC7 Release and PHP5.6 quick sorting 20000 data performance experience and new syntax
Recently, Zend PHP7 is in the final BUG fixing stage, and RC7 has been updated. The performance of Zend official statement PHP7 is more than twice as high as that of PHP5, some new syntaxes were added, some factors affecting the performance of PHP5 were discarded, and the following Features were added.
- Improved performance: PHP 7 is up to twice as fast as PHP 5.6 performance is improved by 2 times than 5.6 Consistent 64-bit support 64-bit consistency support unsupported fatal errors are now supported tions add Many fatal error Exceptions Removal of old and unsupported SAPIs and extensions removes The old unsupported SAPIS and some extensions of The null coalescing operator (??) The empty merge Operator Combined comparison Operator (<=>) is used together with the Return value Type Scalar Type Declarations, which is displayed in the same way as the Return Type Declarations and C language. the Scalar Type defines the Anonymous Classes Anonymous class! I have installed PHP5.5 and PHP7 RC7 Release at the same time, and I have tried PHP7 performance improvements and new syntaxes. As for how to install and configure PHP7, I don't need to say anything, not much nonsense.
Http://php.net/php7 RC7 Release official address
Https://wiki.php.net/rfc/scalar_type_hints_v5 PHP7 wiki
1. PHP7 and PHP5.5 compared to PHP5.6, the performance of PHP7 has improved significantly. here we will use a simple and silly code to test it, here I will use PHP 5.5 to compare it. on the computer, only PHP 5.5 is too lazy to install PHP5.6.
For example, php7 and php5.5:
1.1 here I will use a short piece of silly code to test PHP:
$high) return ; $begin=$low; $end=$high ; $key=$arr[$begin]; while($begin<$end) {while($begin<$end&&$arr[$end]>=$key) --$end ;$arr[$begin]=$arr[$end];while($begin<$end&&$arr[$begin]<=$key) ++$begin;$arr[$end]=$arr[$begin]; } $arr[$begin]=$key; QuickSort($arr,$low,$begin-1); QuickSort($arr,$begin+1,$high);}$time_start = microtime_float();$arr=array();for($i=0;$i
1.2 Test ResultsAfter running the 20000 random data sorting algorithm in PHP7 and PHP5.5 respectively, the result of PHP7 is 12 times that of PHP5.5 !!!! It seems that PHP7 is about to take over!
The following describes the speed at which PHP7 RC7 and PHP5 run the preceding 20000 data sorting algorithm.
2. PHP 7 new syntax 2.1, scalar type and strong typeFour additional scalar types of int in PHP7
,float
,string
Bool. to use a strong type, you must add commands to the file.
Declare (strict_types = 1) This command must be the first command and only has one usage
The concept of strict type and strong type is that we should discard the concept of type before PHP5.6, because we know that PHP itself is a type language, this is also evidenced by the fact that PHP language performance is extremely low due to type conversion and type check. for example, the following code
If you change the above code to return 1; to run normally, otherwise an error will be reported, which is a strong type constraint of PHP 7. In this mode, if the type is completely discarded.
2.2 strongly typed parameters
Var_dump Returns int (3)
2.3 return type conflict return value type and strong type constraints different will run an exception
getMessage(); }?>
OK. the Scalar Type is not written one by one.
For more information, see: https://wiki.php.net/rfc/scalar_type_hints_v5#php_rfcscalar_type_declarations
2.4. about PHP's Anonymous ClassSimple Anonymous class inheritance
M2()->M1();?>
Simple Anonymous class instantiation
i = $i; }});?>
Http://www.bkjia.com/PHPjc/1075799.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1075799.htmlTechArticlePHP7 RC7 Release comparison PHP5.6 quick sorting 20000 data performance experience and new syntax early adopters Zend PHP7 has been in the final BUG fixing stage, has updated RC7, for Zend official...