Benchmarking PHP performance 5.0 to 5.3
Recently I stumbled over article by Johannes Schlüter announcing amazing +20-30% performance increase in new PHP release.
I started to wonder about performance gains between major PHP versions. Here are my benchmark results for versions 5.0.0 up to latest 5.3.5. (at the time of writing):
Fig. 1 - Increase in performance between PHP 5.0.0 against PHP 5.3.5 is about 300 - 350 %
Benchmarking scenario:
- WAMP server with apache 1.3 (original intention to include also PHP 4 benchmarks) and installed PHP versions 5.X.X
- hardware configuration is irrelevant since all PHP versions run on the same machine (Win32, 3GB RAM)
- standard benchmarking script by Zend
PHP Version | Execution time [secs] | Performance gain [%] |
---|---|---|
5.0.0 | 28,03 | ? |
5.0.5 | 26,17 | - |
5.1.0 | 13,21 | cca +100 % |
5.1.4 | 13,29 | - |
5.1.6 | 13,47 | - |
5.2.0 | 12,11 | - |
5.2.9-2 | 11,69 | - |
5.2.11 | 12,59 | - |
5.3.0 | 12,61 | - |
5.3.1 | 12,12 | - |
5.3.3 | 8,16 | cca +50 % |
5.3.5 | 8,20 | - |
Fig. 2 - Summarized benchmark results
Detailed benchmark results for each PHP version
PHP VERSION: 5.0.0 ================== simple 1.061 simplecall 0.744 simpleucall 1.289 simpleudcall 1.418 mandel 4.188 mandel2 4.981 ackermann(7) 2.320 ary(50000) 0.146 ary2(50000) 0.130 ary3(2000) 1.694 fibo(30) 4.867 hash1(50000) 0.200 hash2(500) 0.428 heapsort(20000) 0.982 matrix(20) 0.847 nestedloop(12) 1.644 sieve(30) 0.817 strcat(200000) 0.279 ------------------------ Total 28.034 PHP VERSION: 5.0.5 ================== simple 1.130 simplecall 0.693 simpleucall 1.065 simpleudcall 1.293 mandel 4.085 mandel2 5.055 ackermann(7) 2.071 ary(50000) 0.139 ary2(50000) 0.118 ary3(2000) 1.519 fibo(30) 4.248 hash1(50000) 0.172 hash2(500) 0.402 heapsort(20000) 0.816 matrix(20) 0.769 nestedloop(12) 1.581 sieve(30) 0.746 strcat(200000) 0.271 ------------------------ Total 26.173 PHP VERSION: 5.1.0 ================== simple 0.433 simplecall 0.553 simpleucall 1.007 simpleudcall 1.132 mandel 0.961 mandel2 1.229 ackermann(7) 1.765 ary(50000) 0.091 ary2(50000) 0.083 ary3(2000) 0.541 fibo(30) 3.400 hash1(50000) 0.125 hash2(500) 0.096 heapsort(20000) 0.333 matrix(20) 0.269 nestedloop(12) 0.559 sieve(30) 0.399 strcat(200000) 0.231 ------------------------ Total 13.206 PHP VERSION: 5.1.4 ================== simple 0.411 simplecall 0.463 simpleucall 0.947 simpleudcall 1.167 mandel 0.977 mandel2 1.270 ackermann(7) 1.724 ary(50000) 0.094 ary2(50000) 0.086 ary3(2000) 0.568 fibo(30) 3.534 hash1(50000) 0.127 hash2(500) 0.092 heapsort(20000) 0.346 matrix(20) 0.283 nestedloop(12) 0.549 sieve(30) 0.408 strcat(200000) 0.243 ------------------------ Total 13.289 PHP VERSION: 5.1.6 ================== simple 0.437 simplecall 0.456 simpleucall 0.890 simpleudcall 1.177 mandel 0.976 mandel2 1.293 ackermann(7) 1.723 ary(50000) 0.105 ary2(50000) 0.096 ary3(2000) 0.560 fibo(30) 3.612 hash1(50000) 0.131 hash2(500) 0.099 heapsort(20000) 0.356 matrix(20) 0.291 nestedloop(12) 0.594 sieve(30) 0.422 strcat(200000) 0.249 ------------------------ Total 13.468 PHP VERSION: 5.2.0 ================== simple 0.488 simplecall 0.457 simpleucall 0.919 simpleudcall 1.194 mandel 0.972 mandel2 1.277 ackermann(7) 1.377 ary(50000) 0.047 ary2(50000) 0.039 ary3(2000) 0.532 fibo(30) 3.167 hash1(50000) 0.102 hash2(500) 0.093 heapsort(20000) 0.321 matrix(20) 0.271 nestedloop(12) 0.567 sieve(30) 0.247 strcat(200000) 0.041 ------------------------ Total 12.111 PHP VERSION: 5.2.9-2 ==================== simple 0.469 simplecall 0.461 simpleucall 0.844 simpleudcall 1.012 mandel 0.964 mandel2 1.190 ackermann(7) 1.307 ary(50000) 0.047 ary2(50000) 0.043 ary3(2000) 0.477 fibo(30) 3.360 hash1(50000) 0.096 hash2(500) 0.085 heapsort(20000) 0.296 matrix(20) 0.240 nestedloop(12) 0.515 sieve(30) 0.245 strcat(200000) 0.036 ------------------------ Total 11.686 PHP VERSION: 5.2.11 ================== simple 0.446 simplecall 0.514 simpleucall 0.932 simpleudcall 1.172 mandel 0.969 mandel2 1.250 ackermann(7) 1.416 ary(50000) 0.055 ary2(50000) 0.046 ary3(2000) 0.541 fibo(30) 3.589 hash1(50000) 0.104 hash2(500) 0.094 heapsort(20000) 0.329 matrix(20) 0.274 nestedloop(12) 0.548 sieve(30) 0.266 strcat(200000) 0.041 ------------------------ Total 12.586 PHP VERSION: 5.3.0 ================== simple 0.476 simplecall 0.712 simpleucall 1.117 simpleudcall 1.097 mandel 1.273 mandel2 1.151 ackermann(7) 1.084 ary(50000) 0.061 ary2(50000) 0.065 ary3(2000) 0.716 fibo(30) 2.947 hash1(50000) 0.129 hash2(500) 0.085 heapsort(20000) 0.357 matrix(20) 0.302 nestedloop(12) 0.653 sieve(30) 0.340 strcat(200000) 0.044 ------------------------ Total 12.609 PHP VERSION: 5.3.1 ================== simple 0.489 simplecall 0.728 simpleucall 1.067 simpleudcall 1.050 mandel 1.220 mandel2 1.282 ackermann(7) 1.024 ary(50000) 0.059 ary2(50000) 0.052 ary3(2000) 0.653 fibo(30) 2.609 hash1(50000) 0.130 hash2(500) 0.085 heapsort(20000) 0.322 matrix(20) 0.291 nestedloop(12) 0.687 sieve(30) 0.329 strcat(200000) 0.044 ------------------------ Total 12.121 PHP VERSION: 5.3.3 ================== simple 0.373 simplecall 0.538 simpleucall 0.652 simpleudcall 0.642 mandel 0.879 mandel2 1.081 ackermann(7) 0.503 ary(50000) 0.050 ary2(50000) 0.043 ary3(2000) 0.410 fibo(30) 1.530 hash1(50000) 0.103 hash2(500) 0.087 heapsort(20000) 0.263 matrix(20) 0.229 nestedloop(12) 0.480 sieve(30) 0.255 strcat(200000) 0.038 ------------------------ Total 8.156 PHP VERSION: 5.3.5 ================== simple 0.366 simplecall 0.544 simpleucall 0.544 simpleudcall 0.672 mandel 0.877 mandel2 1.111 ackermann(7) 0.533 ary(50000) 0.051 ary2(50000) 0.044 ary3(2000) 0.416 fibo(30) 1.580 hash1(50000) 0.106 hash2(500) 0.088 heapsort(20000) 0.252 matrix(20) 0.251 nestedloop(12) 0.479 sieve(30) 0.244 strcat(200000) 0.037 ------------------------ Total 8.196
Conclusion
Since version PHP 5.0.X up to PHP 5.3.5 we can see about 350% gain in performance. This is mainly caused by significantly improved memory management.
The most significant performance increase is noteable for 5.1.0 and 5.3.3 version. Performance improvements may also be expected in forthcoming PHP 5.4. Unfortunatelly, I was not able to install PHP 5.4 alpha2 release into WAMP environment since alpha releases are not supplied with apache 1.3.X binaries.