PHP 5.4 Benchmarks

Today I’m giving my first ever talk at OSCON – about PHP 5.4 (I’ll also be giving my second ever talk at OSCON, about RESTful services; it’s a busy day!). My talk includes some benchmarks which I thought I’d also share here, mostly because I like pretty graphs – and this one is pretty:

graph comparing performance of PHP versions

This graph shows the performance of four versions of PHP (because the bench.php script that lives in the php source tree didn’t appear until 5.1). The axis up the left is the time it took to run the benchmark script – so a smaller number is better news.

For each run:

  • I grabbed PHP source code for the newest version of each of PHP 5.1 through to PHP 5.4 (and then had to do that again 2 weeks later when we released new versions of PHP 5.3 and 5.4)
  • Compiled them with their “vanilla” settings – none of these versions has any extensions added or is the PHP version I actually use
  • Ran the bench.php script 10 times and collected the data (full table below)
  • Averaged the data and put it on the nice google chart

If you’re interested in the raw numbers, this is what I have:

Version run0 run1 run2 run3 run4 run5 run6 run7 run8 run9 avg
PHP 5.1.6 3.985 4.038 3.912 3.966 4.006 3.963 3.973 3.939 3.969 3.981 3.9732
PHP 5.2.17 4.28 4.147 4.005 4.071 4.116 4.096 4.054 4.099 4.077 4.103 4.1048
PHP 5.3.14 2.786 2.831 2.762 2.789 2.761 2.972 2.825 2.772 2.749 2.753 2.8
PHP 5.4.4 2.441 2.237 2.228 2.216 2.216 2.224 2.232 2.229 2.237 2.251 2.2511

(with thanks to textfixer.com for a CSV->HTML table conversion tool)

So there you have it: PHP 5.4 is measurably faster than the previous versions of PHP 5.3 (but not twice as fast). Time to upgrade?

25 thoughts on “PHP 5.4 Benchmarks

  1. lower memory usage and the new features are also good reasons to upgrade (if you can). but many webhosts will not switch to 5.4 this year.

  2. Pingback: PHP 5.4 Benchmarks | LornaJane | Luis Gomes | Scoop.it

    • yes, it’s exactly that bench.php. It doesn’t seem to spit out information about memory usage, although it does give a really comprehensive breakdown of how much time each segment of the benchmark took (I have these numbers from when I did the above benchmarks, if anyone wants them)

  3. Pingback: Programowanie w PHP » Blog Archive » Lorna Mitchell: PHP 5.4 Benchmarks

  4. Pingback: PHP 5.4 Benchmarks | Open Source Code | Scoop.it

  5. Did anybody care to scan the source-code of PHP and provide metrics? I mean: it’s nice to know that this runs X seconds faster on your machine than with the old version, but may not give me a good prediction for other software on other hardware. Only if you could provide the number of operations required for an average set of commands and show that there are Y percent less operations than before, this would give us a clear prediction of the average performance increase we are to expect from an upgrade on any software and any machine.

    • Every application is different, this is a very general picture of whether the performance is improved between PHP versions, for comparable and generic code – how much it is improved for your application, on your hardware, with your traffic patterns can only be established by testing exactly that! It’s usual for people to upgrade PHP on one webhead and observe how their monitoring output changes to get a clearer idea of the impact of the upgrade – you just can’t generalise for something so specific I’m afraid

  6. There are some web-hosting that are using php version 5.2 and call it as a stable version :D (funny)
    If they upgrade to 5.3, it would be a great job, let alone upgrading to php version 5.4 :)

    Anyway, benchmark was great,
    Thank you

      • Why is that? Have you had some issues with PHP 5.4? I haven’t had that experience at all but I’d be interested to hear how it was for others

  7. Pingback: JQueryin | PHP 5.4 Benchmark Performance

  8. Pingback: PHP verziók futásideje | Bejegyzések főleg az informatika területéről

  9. Pingback: New PHP 5.4 and ASP.NET 4.5Organic Solutions Corporate Blog | Organic Solutions Corporate Blog

  10. Pingback: Easy Wins For More Performant PHP - SitePoint

  11. Pingback: Why I'm excited for Magento2 and you should be too | Demac Media

  12. Pingback: In-depth Analysis of New Magento2 Development Updates

  13. Pingback: New PHP 5.4 and ASP.NET 4.5 | The Organic Group

  14. Pingback: PHP 5.4 - entwickler.de

  15. What are you thoughts on PHP 7 performance. I have seen the benchmarks on Cloudways platform (https://www.cloudways.com/en/php-cloud-hosting.php ). It was tested with wordpress and the result was 37,378 hits with 0 errors and 0 timeouts. Average response time was an impressive 4ms on vanilla WordPress 4.4 with caching. I believe it is amazing and people should update to this version.

  16. Pingback: PHP 7 Benchmarks | LornaJane

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

This site uses Akismet to reduce spam. Learn how your comment data is processed.