Large contrast of PHP4 and PHP5 performance

Source: Internet
Author: User
Tags inheritance new features

PHP 4 will no longer support PHP group by the end of this year. So in order to let everyone more confident transfer to the PHP 5 platform, I specifically did this test to see if our PHP 4.x really performance than our PHP 5.x better pinch, test results are very obvious, that is, PHP 5.x than PHP 4.x, whether object-oriented or process-oriented, faster than PHP 4.x, so it is absolutely necessary to transfer to the PHP 5.x platform, to experience the PHP 5.x platform of various functions and performance.

Because PHP 5 includes new object models, more new features, faster processing speed, especially for object-oriented code, although the speed of object-oriented code in PHP 4 is more general, But the speed of object-oriented code in php5.x is faster than process-oriented, so don't be skeptical about object-oriented performance, as the following test results illustrate.

"Test Environment"

* Cpu:intel PENTIUM4 2.66GHz

* MEMORY:1GB

* DISK:73GB/SCSI

* Os:freebsd 4.11

* Web:apache 1.3.37

Test tool: AB (also can choose Http_load)

Noun rps:requests per second (number of requests/sec)

"PHP 4.4.2 Test Results"

[Functional Function]

Test result: The result of Ab-n 10000-c 50 is 1047.23/rps

[Classes class]

Do not instantiate class

Test result: The result of Ab-n 10000-c 50 is 1034.98/rps

Instantiating classes

Test result: The result of Ab-n 10000-c 50 is 1006.14/rps

Inheritance of Classes

Test result: The result of Ab-n 10000-c 50 is 992.95/rps

"PHP 5.2.1 Test Results"

[Functional Function]

Test result: The result of Ab-n 10000-c 50 is 1176.06/rps

[Classes class]

Do not instantiate class

Test result: The result of Ab-n 10000-c 50 is 1197.17/rps

Instantiating classes

Test result: The result of Ab-n 10000-c 50 is 1187.93/rps

Inheritance and abstraction of classes

Test result: The result of Ab-n 10000-c 50 is 1128.54/rps

"Test results and analysis"

[Test result data]

Version function test does not instantiate class instantiation of class class do

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. Overall, you can obviously just see PHP5.2 performance is slightly higher than PHP4.4, so do not suspect PHP5.2 performance will be poor, obviously faster than PHP4

2. The parsing performance of classes in PHP4.4 is significantly slower than function, especially when inheritance is used, and it is more degraded, so it is more appropriate to use process-oriented and not-inherited class operations in PHP4.4

3. In PHP5.2, the result is that the class executes faster than the function, and can see that PHP5.2 's engine takes a lot of effort to object-oriented processing, and that they perform well both in function and class.

4. With this test, we have every reason to upgrade the PHP4 to PHP5 in the unlikely event of a code change, and PHP5 basic backward-compatible PHP4 code, in addition to some special code. In addition to the above mentioned the end of this year, the PHP group will no longer continue to maintain the PHP4, so early upgrades, early peace of mind.



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.