Home  >  Article  >  Backend Development  >  Compare the running efficiency of php7 and php 5.5

Compare the running efficiency of php7 and php 5.5

coldplay.xixi
coldplay.xixiforward
2021-01-27 09:55:051495browse

Compare the running efficiency of php7 and php 5.5

Recommended (free): PHP7

Read the website’s php7 installation article step by step After a lot of hard work, I finally installed php7.

php7 installation tutorial address:

http://www.hcoder.net/books/read_10101.html

It is said that php7 runs extremely efficiently, is it true? Let me try it myself. The code is as follows:

<?php
$stratTime   = microtime(true);
$startMemory = memory_get_usage();
$a = 1;for($i = 1; $i <= 100000; $i++){
	$a++;}echo $a;$endTime    = microtime(true);$runtime    
	= ($endTime - $stratTime) * 1000; 
	//将时间转换为毫秒$endMemory  = memory_get_usage();
	$usedMemory = ($endMemory - $startMemory) / 1024;echo "运行时间: {$runtime} 毫秒<br />";echo "耗费内存: {$usedMemory} K";

The above code records the time and memory consumed by php running 100,000 cycles.

php7 operation situation

100001运行时间: 3 - 7 毫秒耗费内存: 0.109375 K

php5.5 operation situation

100001运行时间: 18 - 30 毫秒耗费内存: 0.671875 K

It seems that it is really much faster! ! ! Time saved 6 times, memory saved 6 times. Very good data!

However, webmasters still need to be cautious when upgrading php7, because many plug-ins have not been updated yet! For example, the latest memcache extension has not been released yet...

We can learn the changes of php7 in advance and use them decisively when it matures! !

The above is the detailed content of Compare the running efficiency of php7 and php 5.5. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete