The Computer Language
22.05 Benchmarks Game

Fastest cpu secs PHP versus Python 3

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 cpu seconds, less gz source code.

fannkuch-redux
source mem gz cpu
PHP #2 12,612 441 190.33
PHP #3 12,624 1160 230.54
PHP #4 47,808 1162 232.59
PHP 12,764 482 237.28
Python 3 #6 7,432 385 1,279.15
Python 3 #4 45,420 950 1,336.72
n-body
source mem gz cpu
PHP #3 12,372 1082 66.39
Python 3 7,756 1196 575.02
Python 3 #2 8,244 1242 592.71
spectral-norm
source mem gz cpu
PHP 35,208 1152 27.96
PHP #2 13,444 397 55.81
PHP #3 40,068 1210 60.02
Python 3 #6 9,332 328 436.79
Python 3 #8 48,336 407 472.82
Python 3 #7 48,400 417 494.32
mandelbrot
source mem gz cpu
PHP 12,664 449 86.95
PHP #3 140,544 875 92.75
Python 3 #7 46,192 688 706.10
Python 3 #5   Failed  
Python 3 #2   Timed Out  
pidigits
source mem gz cpu
PHP #5 13,728 399 0.92
PHP #4 13,656 389 0.93
PHP #3 13,804 504 0.95
Python 3 #3 11,968 567 1.13
PHP #2 14,172 545 1.46
Python 3 #4 8,668 342 4.06
PHP 14,912 750 329.76
Python 3 #2   Bad Output  
regex-redux
source mem gz cpu
Python 3 #2 111,680 1403 2.66
PHP 178,712 816 3.66
Python 3 458,264 512 17.86
fasta
source mem gz cpu
PHP #3 12,448 1062 20.99
PHP #2 12,696 1050 28.67
Python 3 #2 8,184 1121 60.26
Python 3 #3 8,112 1003 60.50
Python 3 8,040 817 70.54
Python 3 #5 837,684 1947 71.74
k-nucleotide
source mem gz cpu
PHP #4 257,260 1079 69.91
Python 3 #3 252,668 1967 172.53
Python 3 351,092 607 240.16
Python 3 #8 473,988 655 242.16
reverse-complement
source mem gz cpu
Python 3 #2 1,786,488 434 9.38
Python 3 1,979,276 479 9.63
PHP 1,487,780 318 9.64
Python 3 #6 1,005,184 814 10.64
PHP #3 528,172 446 11.26
PHP #2 1,784,488 281 11.31
Python 3 #4 4,001,684 335 12.31
binary-trees
source mem gz cpu
PHP #3 1,561,956 428 51.64
PHP #2 748,408 423 62.27
PHP 748,424 451 62.40
PHP #4 1,558,972 779 62.76
PHP #7 1,589,184 760 64.15
PHP #5 803,212 1040 85.70
PHP #6 802,924 868 90.44
Python 3 #2 270,872 338 148.09
Python 3 #5 273,284 660 172.44
Python 3 #4 456,220 472 176.37
Python 3 282,996 589 178.66
Python 3 #3 669,832 1238 230.73
PHP

PHP 8.1.5 (cli)
(built: May 5 2022 10:44:00) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.5,
Copyright (c) Zend Technologies

Python 3

Python 3.10.4