The Computer Language
24.09 Benchmarks Game

Python 3 versus PHP fastest performance

How the programs are written matters! Always look at the source code.

If the fastest programs are hand-written vector instructions, does the host language matter? You might be more interested in the less optimised programs — more seconds, less gz source code.

fannkuch-redux
source secs mem gz cpu secs
PHP #2 190.06 19,804 447 190.05
PHP #3 56.00 19,804 1166 222.44
PHP #4 56.07 19,804 1168 222.96
PHP 225.15 19,804 488 225.14
Python 3 #6 1,033.31 19,312 391 1,033.27
Python 3 #4 302.37 19,312 960 1,196.45
PHP #8 1,527.51 19,440 477 1,527.44
Python 3 #8 2,259.59 19,312 414 2,259.50
n-body
source secs mem gz cpu secs
PHP #8 65.86 19,440 1245 65.85
PHP #3 66.53 19,804 1088 66.52
Python 3 355.06 19,312 1201 355.05
Python 3 #2 374.16 19,312 1247 374.14
Python 3 #8 518.11 19,312 1172 518.09
spectral-norm
source secs mem gz cpu secs
PHP 6.87 19,804 1157 27.14
PHP #2 57.15 19,804 403 57.15
PHP #3 16.34 19,804 1214 64.01
Python 3 #6 347.53 19,316 334 347.52
Python 3 #4 90.52 19,308 415 359.95
Python 3 #8 379.97 19,440 334 379.96
Python 3 #7 97.11 19,316 425 380.79
mandelbrot
source secs mem gz cpu secs
PHP 87.00 19,804 452 87.00
PHP #3 23.38 48,256 881 93.15
Python 3 #7 172.20 19,312 698 687.68
Python 3 #3 861.76 19,312 319 861.73
Python 3 #2 235.71 95,164 790 926.30
Python 3 #5 257.00 19,312 463 1,026.96
pidigits
source secs mem gz cpu secs
PHP #5 0.96 19,932 405 0.96
PHP #4 0.98 19,804 396 0.98
PHP #3 0.98 19,804 510 0.98
Python 3 #3 1.26 19,312 573 1.26
PHP #2 1.47 19,932 552 1.47
Python 3 #4 4.54 19,312 348 4.54
PHP 335.40 19,804 756 335.39
Python 3 #5   Failed  
regex-redux
source secs mem gz cpu secs
Python 3 #2 1.35 168,236 1411 2.64
PHP 1.85 194,856 822 3.72
Python 3 8.91 432,220 515 16.44
fasta
source secs mem gz cpu secs
PHP #3 21.15 19,804 1065 21.14
PHP #2 29.41 19,804 1054 29.41
Python 3 #2 39.00 19,312 1126 39.00
Python 3 #3 39.12 19,312 1007 39.12
Python 3 #5 27.86 827,284 1951 53.94
Python 3 57.21 19,312 823 57.20
Python 3 #8 259.98 19,312 730 259.80
PHP #8 265.71 27,768 742 265.18
k-nucleotide
source secs mem gz cpu secs
PHP #4 21.61 260,560 1290 69.80
Python 3 #3 50.15 262,368 1970 185.77
Python 3 #8 236.77 623,232 522 235.97
Python 3 #4 79.01 506,112 663 236.67
Python 3 238.45 499,072 499 237.78
Python 3 #9 68.33 379,392 614 238.74
reverse-complement
source secs mem gz cpu secs
Python 3 #3 4.86 507,712 803 4.86
Python 3 #5 4.09 1,500,716 960 7.41
PHP 9.89 1,489,328 323 9.89
Python 3 #2 10.08 1,788,136 440 10.08
Python 3 10.29 1,986,440 484 10.29
Python 3 #6 7.38 2,484,372 821 10.89
PHP #2 11.75 1,787,280 288 11.75
PHP #3 7.75 536,668 452 12.24
Python 3 #4 13.41 4,002,688 343 13.41
binary-trees
source secs mem gz cpu secs
PHP #3 46.07 921,600 434 46.07
PHP #7 15.58 948,608 767 56.00
PHP #4 18.34 918,528 786 56.94
PHP 61.97 748,788 457 61.97
PHP #2 63.25 748,792 429 63.24
PHP #5 33.17 805,512 1048 84.83
PHP #6 27.48 805,532 877 91.38
PHP #8 92.50 750,592 590 92.49
Python 3 #2 100.90 271,872 344 100.89
Python 3 #4 33.61 276,992 481 121.96
Python 3 #5 35.49 274,816 669 126.17
Python 3 36.12 276,992 597 127.68
Python 3 #3 52.28 671,872 1247 149.07
Python 3 #8 558.92 798,336 535 558.85
Python 3

Python 3.13.0

PHP

PHP 8.3.11 (cli)
(built: Sep 5 2024 12:34:23) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.11,
with Zend OPcache v8.3.11,
Copyright (c) Zend Technologies