Reasons to upgrade PHP5: PHP4 and PHP5 performance comparison _php Tutorials

Source: Internet
Author: User
PHP 4 to the end of this year, the PHP group will no longer support it, so in order to let people more confident transfer to the PHP 5 platform, I specifically did this test, to see if our PHP 4.x is really better than our PHP 5.x pinch, the test results are obvious, that is PHP 5.x The PHP 4.x is faster than PHP 4.x for both object-oriented and process-oriented, so it's absolutely necessary to move on to the PHP 5.x platform to experience the various functions and performance of the PHP 5.x platform.

Because PHP 5 includes the new object model, more new features, faster processing speed, especially the speed of object-oriented code, although in PHP 4, object-oriented code is more common, But 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 will show.

"test Environment"
    • Cpu:intel Pentium4 2.66GHz
    • Memory:1gb
    • Disk:73gb/scsi
    • Os:freebsd 4.11
    • Web:apache 1.3.37
      Test tool:AB (can also choose http_load)
      Nominal RPS: requests per second (number of requests per second)
related

Test tools: AB(You can also choose Http_load)

Term RPS: Requests per second(Number of requests per second)

   "PHP 4.4.2 test Results"

[Functional Function]

function signin () {
echo "Test";
}
Signin ();
?>
Test result: The result of Ab-n 10000-c 50 is 1047.23/rps

[Classes class]

Do not instantiate a class

Class user{
function signin () {
echo "Test";
}
}
User::signin ();
?>
Test result: The result of Ab-n 10000-c 50 is 1034.98/rps

Instantiating classes

Class user{
function signin () {
echo "Test";
}
}
$user =new User ();
$user->signin ();
?>
Test result: The result of Ab-n 10000-c 50 is 1006.14/rps

Inheritance of Classes

Class auser{
function signin () {}
}
Claāss User extends auser{
function signin () {
echo "Test";
}
}
$user =new User ();
$user->signin ();
?>
Test result: The result of Ab-n 10000-c 50 is 992.95/rps

   "PHP 5.2.1 test Results"

[Functional Function]

function signin () {
echo "Test";
}
Signin ();
?>
Test result: The result of Ab-n 10000-c 50 is 1176.06/rps

[Classes class]

do not instantiate a class

Class user{
Public Function signin () {
echo "Test";
}
}
User::signin ();
?>
Test result: The result of Ab-n 10000-c 50 is 1197.17/rps

Instantiating Classes

Class user{
Public Function signin () {
echo "Test";
}
}
$user =new User ();
$user->signin ();
?>
Test result: The result of Ab-n 10000-c 50 is 1187.93/rps

inheritance and abstraction of classes

Abstract class auser{
Abstract function signin ();
}
Class User extends auser{
Public Function signin () {
echo "Test";
}
}
$user =new User ();
$user->signin ();
?>
Test result: The result of Ab-n 10000-c 50 is 1128.54/rps

"Test results and analysis"

[test result data]

Version function test Do not instantiate a class Instantiating classes The secondary ā of the class
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, can obviously just see PHP5.2 performance is slightly higher than PHP4.4, so do not suspect PHP5.2 performance will be poor, significantly faster than PHP4

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

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

4.
With this test, we had every reason to upgrade the PHP4 to PHP5 with little change in code, and PHP5 basically backwards-compatible PHP4 code, except for some special code. Also mentioned above the end of this year, the PHP group will no longer continue to PHP4 maintenance, so early upgrade, early peace of mind.

http://www.bkjia.com/PHPjc/509196.html www.bkjia.com true http://www.bkjia.com/PHPjc/509196.html techarticle PHP 4 to the end of this year the PHP group will no longer support it, so in order to let people more confident transfer to the PHP 5 platform, I specifically did this test to see if our PHP 4.x really ...

  • Related Article

    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.