2.2.4 PerformanceThis is NOT the latest copy of this book; click here for the latest version.
Prior to the release of PHP 4, Perl mongers were more than happy to offer head-to-head tests between a PHP script and a similar Perl script, because they were safe in the knowledge that Perl outperformed PHP pretty much hands-down. However, since PHP 4, and particularly since PHP 4.1, PHP has really made big progress in terms of raw speed - in PHP 5.1 (still under development at the time of writing) speed is one of the primary areas targeted for improvement.
The change between v3 and v4 was largest, though - to give you an idea of the speed improvement, I wrote a simple test script that works in both PHP 3 and PHP 4. It simply creates an array of 1000 different random numbers, then sorts the array. When executing this script 1000 times, PHP 3 managed to achieve 19.51 requests per second on a 500MHz Linux box, compared to PHP 4's 43.08 requests per second - quite a difference, and the program was only four lines long!
So, PHP 4 performance was certainly nothing to be sniffed at. You will see a much bigger performance difference when using a more complicated script, and even higher numbers if you use one of the many PHP accelerator packages available.
Later on in the book I will be discussing how to maximise your script performance by eking out every drop of performance available.
|
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.
My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!
|