The Computer Language
25.03 Benchmarks Game

Python 3 versus PHP

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

If the fastest programs are flagged * possible hand-written vector instructions or "unsafe" or naked ffi, does the host language matter? You might be more interested in the less optimised programs — more seconds, less gz source code.

fannkuch-redux      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
PHP #2 464.80 463.62 16,339 447
PHP #4 130.83 514.56 19,780 1168
PHP #3 133.01 525.32 19,767 1166
PHP 592.64 591.45 16,400 488
PHP #8 847.77 849.92—863.13 16,364 458
Python 3 #6 943.88 942.63 11,874 391 3.58
Python 3 #4 311.18 1,221.85 28,701 960 5.27
Python 3 #8 2,457.09 2,455.59 11,874 414 5.65
n-body      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
PHP #3 204.10 204.15—204.79 16,425 1088
PHP #8 242.35 242.50—244.36 16,507 1245
Python 3 372.41 371.23 12,198 1201 5.23
Python 3 #2 442.06 440.87 12,554 1247 5.24
Python 3 #8 529.38 528.16 12,497 1172 4.94
spectral-norm      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
PHP 18.29 72.34—72.52 24,682 1157
PHP #2 132.84 132.71—133.29 16,810 403
PHP #8 135.79 136.38—136.78 16,601 357
PHP #3 35.62 141.27—141.39 26,657 1214
Python 3 #6 349.68 348.48 13,660 334 5.44
Python 3 #4 90.37 352.91 34,693 415 5.41
Python 3 #8 386.45 385.07 12,833 334 5.08
Python 3 #7 109.91 421.84 34,578 425 5.30
mandelbrot      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
PHP 258.19 257.96—264.71 16,437 452
PHP #3 68.29 273.64—275.67 53,531 881
PHP #8 424.00 422.73 49,336 419
Python 3 #7 182.94 723.28 62,173 698 5.52
Python 3 #3 879.41 877.96 45,085 319 5.26
Python 3 #2 237.64 937.87 230,973 790 5.42
Python 3 #5 260.63 1,033.16 61,620 463 5.48
Python 3 #8 1,577.29 1,575.80 45,031 379 4.84
fasta      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
PHP #3 31.10 31.07—31.17 16,433 1065
Python 3 #3 39.03 38.30—47.80 12,218 1007 5.32
Python 3 #2 39.06 38.61—46.82 12,415 1126 5.21
PHP #2 47.59 47.60—47.80 16,388 1054
PHP #8 49.83 49.85—49.96 16,388 760
Python 3 #5 27.95 54.20—54.96 1,190,347 1951 5.52
Python 3 57.39 56.94—65.76 12,100 823 5.06
Python 3 #8 153.17 153.78—158.43 11,915 738 5.04
k-nucleotide      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
PHP #8 79.70 80.05—80.48 649,593 571
PHP #4 25.77 89.39—89.89 270,369 1290
Python 3 #3 46.55 182.32—187.37 674,185 1970 5.68
Python 3 #4 76.67 233.00—239.32 523,751 663 4.89
Python 3 #8 234.08 235.36—236.89 642,265 525 5.15
Python 3 234.20 235.10—237.16 515,047 499 5.34
Python 3 #9 66.67 236.43—238.45 392,184 614 4.09
reverse-complement      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Python 3 #3 4.96 4.95 523,801 803 5.28
Python 3 #5 4.18 7.46—7.50 2,418,156 960 5.36
Python 3 #2 10.09 10.13—10.24 1,837,285 440 5.32
PHP 10.35 10.35 1,531,154 323
Python 3 10.43 10.43—10.59 2,040,713 484 5.28
Python 3 #6 7.59 11.07—11.11 2,795,930 821 5.37
PHP #2 12.31 12.31—12.35 1,836,716 288
PHP #3 8.29 12.59 1,821,659 452
Python 3 #4 13.47 13.44—13.88 4,109,324 343 5.05
binary-trees      [ Contentious. Different approaches. ]
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
PHP #3 69.00 69.05—69.23 948,552 434
PHP #7 22.24 81.49—81.93 1,316,532 767
PHP #4 24.74 81.31—81.61 1,280,827 786
PHP 90.45 90.68—90.99 771,105 457
PHP #2 93.90 93.86—94.42 771,146 429
Python 3 #2 100.49 100.69—101.09 281,829 344 5.08
Python 3 #4 33.37 121.32—121.68 460,771 481 5.57
Python 3 34.85 123.08—123.98 445,649 597 5.16
PHP #5 47.09 124.17—125.36 1,745,932 1048
Python 3 #5 35.37 125.71—126.12 806,117 669 5.30
PHP #6 38.32 130.46—131.16 2,379,801 877
Python 3 #3 51.88 148.91—149.87 819,077 1247 5.39
pidigits      [ Contentious. Different libraries. ]
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
PHP #5 1.01 1.00 17,302 405
PHP #4 1.02 1.01 17,355 396
PHP #3 1.03 1.02 17,367 510
* Python 3 #3 1.35 1.28—1.32 20,009 573 5.34
Python 3 #5 1.40 1.36 15,606 369 7.20
PHP #2 1.51 1.50 17,756 552
Python 3 #4 4.63 4.60 12,718 348 4.88
PHP 102.79 102.76—102.81 18,395 756
regex-redux      [ Contentious. Different libraries. ]
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
* Python 3 #2 1.41 2.65 191,300 1411 5.48
PHP 1.88 3.67 203,751 822
Python 3 8.96 16.47—16.75 459,624 515 5.47
Python 3

Python 3.13.0

PHP

PHP 8.4.1 (cli)
(built: Nov 22 2024 14:22:47) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.1,
with Zend OPcache v8.4.1,
Copyright (c) Zend Technologies