search
HomeBackend DevelopmentPHP7About the performance comparison between PHP5 and PHP7

About the performance comparison between PHP5 and PHP7

The interpreter of PHP is Zend Engine. Enter the Zend directory of the source code package. This is the core part of PHP and is mainly responsible for the syntax implementation of PHP. , memory management and script compilation and running environment, etc.

Related tutorials: "PHP7"

/opt/softpackage/php-5.6.8/Zend
/opt/softpackage/php-7.2.33/Zend
/opt/softpackage/php-7.4.0/Zend

Find the test file bench.php. There are a lot of test codes written in this file, such as

// 执行一百万次字符串 hallo 长度的计算
function simplecall() {
  for ($i = 0; $i < 1000000; $i++)
    strlen("hallo");
}

Execute /usr/local/php-5.6.8/bin/php bench.php, the test results are as follows

simple             0.657
simplecall         1.980
simpleucall        1.712
simpleudcall       1.935
mandel             2.531
mandel2            2.860
ackermann(7)       1.101
ary(50000)         0.282
ary2(50000)        0.147
ary3(2000)         1.557
fibo(30)           5.309
hash1(50000)       0.362
hash2(500)         0.348
heapsort(20000)    1.564
matrix(20)         0.857
nestedloop(12)     0.796
sieve(30)          0.737
strcat(200000)     0.079
------------------------
Total             24.813

Execute /usr/local/php -7.2.33/bin/php bench.php, the test results are as follows

simple             0.089
simplecall         0.037
simpleucall        0.156
simpleudcall       0.169
mandel             0.483
mandel2            0.566
ackermann(7)       0.148
ary(50000)         0.186
ary2(50000)        0.020
ary3(2000)         0.237
fibo(30)           0.519
hash1(50000)       0.062
hash2(500)         0.048
heapsort(20000)    0.120
matrix(20)         0.121
nestedloop(12)     0.265
sieve(30)          0.129
strcat(200000)     0.035
------------------------
Total              3.388

Execute /usr/local/php-7.4.0/bin/php bench.php, The test results are as follows

simple             0.059
simplecall         0.016
simpleucall        0.033
simpleudcall       0.052
mandel             0.144
mandel2            0.135
ackermann(7)       0.042
ary(50000)         0.169
ary2(50000)        0.007
ary3(2000)         0.060
fibo(30)           0.126
hash1(50000)       0.031
hash2(500)         0.028
heapsort(20000)    0.080
matrix(20)         0.049
nestedloop(12)     0.075
sieve(30)          0.030
strcat(200000)     0.014
------------------------
Total              1.151

Through comparison, it is found that the performance of PHP 7 has improved significantly. PHP 5 takes about 25 seconds to execute the test code, while PHP 7 does not exceed 4 seconds. In addition, PHP 7.4 has much better performance than PHP 7.2 improvement. Of course, the test results will be different in different test environments, but the performance improvement is definitely the same.

In addition, the Zend directory also has a more complex test file micro_bench.php. Interested partners can test it by themselves. If the stable version of PHP 8 is officially released, friends can also experience the performance of PHP 8 for themselves.

The above is the detailed content of About the performance comparison between PHP5 and PHP7. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.