Benchmarking PHP performance 5.0 to 5.3

Published on 25.07.2011, by Lubos Dzurik

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):

PHP benchmark chart
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. My original intention was to include also PHP 4.X benchmarks, which however require apache 1.3.X. The bench.php script failed on any PHP 4.X version while 5.4 alpha2 could not be installed with apache 1.3 :-(


Comments...

Edin

26.07.2011 20:53
# 1 Reply to Edin    
 

This is good to know, thanks for testing and sharing results.

Mike

30.09.2011 12:55
# 2 Reply to Mike    
 

Quite interesting. Thanx.

ricardo DOT nuno DOT rodrigues AT hotmail DOT com

27.11.2011 11:54
# 3 Reply to ricardo DOT nuno DOT rodrigues AT hotmail DOT com    
 

Hi there,

Can you test PHP 5.4?

Thanks
Ricardo

lubosdz

27.11.2011 20:54
# 4 Reply to lubosdz    
 

ricardo.nuno.rodrigues@hotmail.com wrote on 27.11.2011 11:54:
Hi there,

Can you test PHP 5.4?

Thanks
Ricardo

Hi,

results provided above have been created for apache and PHP versions compiled against VC6 (C++ compiler supplied with Visual Studio 6). PHP 5.4 is compiled with newer C++ compiler VC9 (Visual Studio 9, C++ compiler).

Here is short overview of which PHP version is compiled againts which compiler:

- PHP 4.x - 5.2.9 with VC6
- PHP 5.3 - 5.3.5 with VC6 or VC9
- PHP 5.4 only VC9


To mess things up even more, also httpd apache server comes in two flavours VC6 or VC9.

So objective benchmarking is only possible:
A/ for PHP 5.0 - 5.3.5 compiled against VC6 and apache VC6
or
B/ for PHP 5.3.0 - 5.4 compiled against VC9 and apache VC9

The results above are provided for variant A/.
To set up environment for variant B/ it would be quite a time consuming task - reinstalling whole environment and creating PHP versions for WAMP server against VC9.

I may update results later once PHP 5.4, PHP 5.4.1 etc.. come out.
Regards
Lubos

ceceldada AT gmail DOT com

23.01.2013 17:00
# 5 Reply to ceceldada AT gmail DOT com    
 

PHP VERSION: 5.4.9
simple 0.330
simplecall 0.731
simpleucall 0.944
simpleudcall 0.916
mandel 0.994
mandel2 1.094
ackermann(7) 0.674
ary(50000) 0.067
ary2(50000) 0.061
ary3(2000) 0.553
fibo(30) 2.175
hash1(50000) 0.129
hash2(500) 0.068
heapsort(20000) 0.271
matrix(20) 0.246
nestedloop(12) 0.561
sieve(30) 0.262
strcat(200000) 0.039


Total 10.115
Memory (MB): 0.36

lubosdz

23.01.2013 21:11
# 6 Reply to lubosdz    
 

ceceldada@gmail.com wrote on 23.01.2013 17:00:
PHP VERSION: 5.4.9
simple 0.330
simplecall 0.731
simpleucall 0.944
simpleudcall 0.916
mandel 0.994
mandel2 1.094
ackermann(7) 0.674
ary(50000) 0.067
ary2(50000) 0.061
ary3(2000) 0.553
fibo(30) 2.175
hash1(50000) 0.129
hash2(500) 0.068
heapsort(20000) 0.271
matrix(20) 0.246
nestedloop(12) 0.561
sieve(30) 0.262
strcat(200000) 0.039
Total 10.115
Memory (MB): 0.36

Hi,
your results benchmark for PHP 5.4.X have no real meaning here - they are inobjective since PHP 5.4.9 cannot be configured with the same environment as all benchmarks above -
apache VC6, win x32, 3 GB RAM, same processor...

If you want to provide valuable results, you must run test for various PHP versions on the same machine, same environment and same PHP configuration.

Leave your comment..
Email will be converted into something like [michael AT gmail DOT com]
Note: Offensive and unrelated comments will be deleted.
Please enter result from the picture above.