Reasons for upgrading PHP5: Performance Comparison between PHP4 and PHP5. PHP4 will not be supported by PHPGroup by the end of this year, so I did this test to make everyone more confident to transfer to the PHP5 platform, let's see if PHP4.x is true. PHP 4 is no longer supported by PHP Group by the end of this year. so to make everyone more confident, I did this test, 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(You can also use http_load)
Term RPS:Requests per second(Number of requests per second)
Related
Test tool:
AB(You can also use http_load)
Term RPS:
Requests per second(Number of requests per second)
PHP 4.4.2 test results]
[Function]
Function signin (){
Echo "test ";
}
Signin ();
?>
Test result: the result of AB-n 10000-c 50 is
1047.23/rps
[Class]
Do not instantiate class
Class User {
Function signin (){
Echo "test ";
}
}
User: signin ();
?>
Test result: the result of AB-n 10000-c 50 is
1034.98/rps
Instantiation class
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
Class inheritance
Class AUser {
Function signin (){}
}
TLS extension 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]
[Function]
Function signin (){
Echo "test ";
}
Signin ();
?>
Test result: the result of AB-n 10000-c 50 is
1176.06/rps
[Class]
Do not instantiate class
Class User {
Public function signin (){
Echo "test ";
}
}
User: signin ();
?>
Test result: the result of AB-n 10000-c 50 is
1197.17/rps
Instantiation class
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
Class inheritance and abstraction
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 testing |
Do not instantiate class |
Instantiation class |
Class inheritance |
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 the performance of PHP5.2 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.
Http://www.bkjia.com/PHPjc/509196.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/509196.htmlTechArticlePHP 4 to the end of this year PHP Group will no longer support it, so in order to make everyone more confident to transfer to the PHP 5 platform, I specifically did this test, check if PHP 4.x is true...