PHP 7.0.0 vs PHP 5.6: Speed and memory usage

It's been a couple of days since the final PHP 7.0.0 was released. Among the new features/improvements brought by this new version are improved speed and reduced memory usage. So they say. It's about time to find out if this is the case.

It's benchmarking time! Version 7.0.0 was committed to portage (Gentoo...) and it just took a few seconds to unmask the package and compile it. The latest stable version in the 5.6 branch at the time of writing this post is 5.6.14 (I doubt vesion 5.6.16 will have significant -if any- improvements in speed and memory usage), so 5.6.14 is the version that will be used to compare against 7.0.0.

What was tested? I have a locally installed web application that uses PostgreSQL as a database backend. From this application a page that queries the database was used (this will be called page with database access in the charts below). Another simple page with no database queries was also used (page without database access). What is measured is the raw speed (requests per second) and peak memory usage for each page (in Kilobytes). The tests were run with and without Opcache enabled just to understand the effect this cache optimizer has in each case.

Requests per second (page with database access)

Peak memory usage in KiB (page with database access)

Requests per second (page without database access)Peak memory usage in KiB (page without database access)

As you can see from the charts, PHP 7.0.0 is a huge improvement in terms of performance and memory usage. For the page with the database queries, version 7.0.0 is more than 3 times faster than 5.6 with opcache enabled and 2.7 times faster without opcache! In terms of memory usage, the difference is also significant! For the page without database access, the differences are relatively smaller than in the first case (version 7.0.0 is 1.4 times faster than 5.6 with opcache and 1.36 times faster without opcache and memory usage is also much smaller for 7.0.0 in any case -with and without opcache-).

In any case, besides any core language features that have been introduced with version 7.0.0 and make PHP a better, more practical and more useful language, the immediate positive effects of speed and memory usage are very much noticable. Kudos to the developers that released a great version after so much work. In terms of raw performance, this version is much like version 5.4 a few years ago, when upgrading from 5.3, and that newer version came with more speed and less memory requirements.

So, version 7.0.0 is going to be a great success! Excellent work guys!

υπολογιστές / computers: 
Χρήσιμο / Useful: 
Average: 5 (1 vote)
Ψηφίστε για την ποιότητα του άρθρου / Vote for the article's quality