Reasons for upgrading PHP5: Performance Comparison between PHP4 and PHP5

Source: Internet
Author: User
Reasons for upgrading PHP5: Performance Comparison between PHP4 and PHP5. read the reason for upgrading PHP5: PHP4 and PHP5 Performance Comparison. PHP4 will not be supported by PHPGroup by the end of this year, so in order to make everyone more confident to transfer to the PHP5 platform, I specifically did this test to see if our PHP4.x is really better than our PHP5.x, and the test is completed "> <LINKh

PHP Group will no longer support PHP 4 by the end of this year, so I did this test to make everyone more confident to transfer to the PHP 5 platform, check if PHP 4.x has a better performance than PHP 5. the test results are obvious because PHP 5.x is better than php 4. x is faster than PHP 4.x in both object-oriented and process-oriented scenarios. Therefore, it is necessary for you to migrate to the PHP 5.x platform to experience various functions and performance of the PHP 5.x platform.

Because PHP 5 includes new object models, more new features, and faster processing speed, especially the processing speed of object-oriented code, although the object-oriented code speed in php 4 is relatively average, however, in PHP5.x, the OSS code speed exceeds the process-oriented speed, so do not doubt the OSS performance. the following test results show all of this.

[Test environment]

* CPU: Intel Pentium4 2.66 GHz
* Memory: 1 GB
* Disk: 73 GB/SCSI
* OS: FreeBSD 4.11
* Web: Apache 1.3.37
Test Tool: AB (http_load can also be used)
Term RPS: Requests per second (number of Requests per second)

PHP 4.4.2 test results]

[Function]

 

Test result: the result of AB-n 10000-c 50 is 1047.23/rps.

[Class]

Do not instantiate class

 

Test result: the result of AB-n 10000-c 50 is 1034.98/rps.

Instantiation class

 

Test result: the result of AB-n 10000-c 50 is 1006.14/rps.
Class inheritance

 

Test result: the result of AB-n 10000-c 50 is 992.95/rps.

[PHP 5.2.1 Test results]

[Function]


Test result: the result of AB-n 10000-c 50 is 1176.06/rps.

[Class]

Do not instantiate class

 

Test result: the result of AB-n 10000-c 50 is 1197.17/rps.

Instantiation class


Test result: the result of AB-n 10000-c 50 is 1187.93/rps.

Class inheritance and abstraction

 

Test result: the result of AB-n 10000-c 50 is 1128.54/rps.
[Test results and analysis]

[Test result data]

Version function testing does not instantiate the inheritance of class instantiation classes
PHP 4.4.2 1047.23/rps 1034.98/rps 1006.14/rps 992.95/rps
PHP 5.2.1 1176.06/rps 1197.17/rps 1187.93/rps 1128.54/rps

[Result analysis]

1. In general, we can see that the performance of PHP5.2 is slightly higher than PHP4.4, so do not doubt that PHP5.2 performance will be poor, obviously faster than PHP4

2. the parsing performance of classes in PHP4.4 is much slower than that of functions, especially when inheritance is used, therefore, PHP4.4 is more suitable for process-oriented and non-inherited class operations.

3. in PHP5.2, the result is that the class execution speed is faster than the function. it can be seen that the PHP5.2 engine has spent a lot of effort on object-oriented processing. at the same time, both functions and classes have good performance.

4. through this test, we have reason to upgrade PHP4 to PHP5 when the code is not changed much, and PHP5 is basically backward compatible with PHP4 code, except for some special code. In addition, PHP Group will not continue to maintain PHP4 after the end of this year, so it is easy to upgrade early.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.