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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
