Proof that PHP 5.4 is Twice as Fast as PHP 5.3
My first attempt at benchmarking the two versions produced this:
This was a surprise to me; was PHP 5.4 really so much faster??
It turns out that it isn’t, and my mistake was to pick a very simple script which only does one thing – and that thing is something that actually was vastly improved between versions! I have a script that runs the same piece of code lots of times and does some crude timings with that – so these numbers are only useful as a relative comparison; I’m just running this stuff on my laptop.
The script:
$r = 10 * 1000 * 1000;
$start = microtime(true);
while($r-- > 0) {
new StdClass();
}
$finish = microtime(true);
echo "time taken: " . ($finish - $start) . "\n";
I ran each test five times and averaged the results (original data: thrown into a gist if you want it).
The moral of this story is: you can prove anything you want with statistics! I’m assembling a more varied script for some rather more useful benchmarks, but just look at how much faster it is to instantiate an object in PHP 5.4! Many thanks to everyone who contributes to the PHP project, the language continues to evolve and improve in so many ways, and I am grateful!
* Apologies for the inflammatory blog post title, but those were my exact words when I got this result set.
Wow. That’s still pretty amazing. There are benchmark scripts in the php src http://news.php.net/php.internals/57760
Supposing that this article is correct it sounds like there could be a number of performance enhancements in 5.4, especially where tight and disciplined coding practices are employed – like avoiding the practice of adding new properties dynamically to objects.
There’s some good work going on with PHP, it’s a great language to work with.
“The only statistics you can trust are those you falsified yourself” Winston Churchill
Wow man :) thats awesome..
Pingback: Programowanie w PHP » Blog Archive » Lorna Mitchell’s Blog: Proof that PHP 5.4 is Twice as Fast as PHP 5.3
Programmers Need To Learn Statistics Or I Will Kill Them All
http://zedshaw.com/essays/programmer_stats.htmla
Pingback: PHP 5.4 e prestazioni | Edit - Il blog di HTML.it
Pingback: PHP 5.4 e prestazioni | Pixelset.it
I’m glad you mentioned that the test was on a simple script. As with all new versions of PHP (any language) there is a push for performance improvements and its good to see the gains in a visual like this.
It would interesting to run the script and others on every version of PHP and see the jumps in progress in a similar visual.
I have some more comprehensive benchmarks in a talk I’m giving at OSCON next month – I’ll try to remember to blog them when I get back
Nice one, That would make a good post
Just ran this test on my machine, interestingly casting (object) array is much quicker than creating stdClass:
5.3.1
new stdClass(): 5.9607532024384
(object) array(): 3.4466769695282
5.4.3
new stdClass(): 3.2519390583038
(object) array(): 2.7573947906494
Pingback: PHP 5.4 Benchmarks | LornaJane
I am actually updating 5.3 to 5.4, It has a lot of new features. If it is fast as you wrote I would be very happy :)
Nice! I’ve had similar results and always recommend client to update to 5.4. Now with 5.5 just around the corner it will be interesting to see how it stacks up. :)
On my test. benchmark testing, it is about 20% faster.
But when I use the real program, such as phpBB 3. It is only 5% improvement on loading.
http://www.yinfor.com/blog/archives/2013/09/php_55_vs_php_54_vs_php_53_-_p.html This is the test of PHP5.5 vs PHP5.4 vs PHP5.3
Pingback: Benchmarking HipHopVM 2.1.0 against PHP 5.3.10 on Ubuntu 12.04 LTS | LeaseWeb Labs
Pingback: Benchmarking HipHopVM 2.2.0: slower, but more compatible | LeaseWeb Labs
Pingback: Why Facebook is making a PHP renaissance | KidsIL
Thanks for the script. I ran it locally and it was very illuminating about the impact XDebug has on performance.
http://jasonrichardsmith.org/blog/loading-xdebug-module-impacts-performace-even-when-diabled