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

Compare the running efficiency of php7 and php 5.5

coldplay.xixi
Release: 2023-02-17 19:14:02
forward
1608 people have browsed it

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";
Copy after login

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

php7 operation situation

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

php5.5 operation situation

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

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!

Related labels:
source:csdn.net
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template