The Computer Language
23.02 Benchmarks Game

Perl versus PHP fastest performance

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 187.39 12,976 441 187.38
PHP #4 54.97 13,440 1162 217.94
PHP #3 55.84 13,500 1160 222.26
PHP 223.52 12,988 482 223.42
Perl #3 1,233.33 10,840 427 1,233.17
Perl #2 421.78 12,164 570 1,677.14
Perl 1,806.93 10,844 457 1,806.70
n-body
source secs mem gz cpu secs
PHP #3 65.75 13,100 1082 65.74
Perl #2 405.03 10,904 1429 404.98
spectral-norm
source secs mem gz cpu secs
PHP 6.81 14,120 1152 26.92
PHP #2 57.19 13,528 397 57.19
PHP #3 16.17 14,188 1210 63.74
Perl #4 25.06 12,116 555 98.69
Perl #5 102.09 10,908 340 102.07
Perl 103.18 10,908 333 103.17
Perl #3 128.66 10,908 850 510.64
Perl #2 529.19 10,908 343 529.02
mandelbrot
source secs mem gz cpu secs
PHP 86.88 13,016 449 86.87
PHP #3 23.25 48,484 875 92.76
Perl 478.47 77,044 586 1,900.78
pidigits
source secs mem gz cpu secs
PHP #5 0.90 14,248 399 0.90
PHP #4 0.91 14,216 389 0.91
PHP #3 0.92 14,324 504 0.92
PHP #2 1.38 14,636 545 1.38
Perl 10.35 12,684 463 10.35
PHP 334.16 15,344 750 334.14
Perl #4   Failed  
Perl #2   Failed  
regex-redux
source secs mem gz cpu secs
PHP 1.82 194,824 816 3.60
Perl 22.52 205,596 464 22.52
Perl #2 17.08 205,220 710 29.44
Perl #4 10.41 157,184 820 30.81
Perl #3 10.52 409,996 854 31.05
Perl #5   Bad Output  
fasta
source secs mem gz cpu secs
PHP #3 21.34 13,084 1062 21.34
PHP #2 28.62 13,048 1050 28.61
Perl 61.00 55,380 871 60.99
Perl #4 123.00 10,896 966 122.68
Perl #2 174.19 10,896 922 173.96
k-nucleotide
source secs mem gz cpu secs
PHP #4 20.80 260,644 1079 70.63
Perl #2 114.21 659,832 359 114.19
Perl #4 40.72 1,069,244 476 127.66
Perl 38.38 1,247,436 652 131.20
Perl #3 51.56 1,146,964 513 168.22
reverse-complement
source secs mem gz cpu secs
Perl #3 6.44 1,495,072 287 6.44
PHP 9.25 1,489,448 318 9.24
PHP #2 10.91 1,787,268 281 10.91
PHP #3 7.09 536,544 446 11.20
binary-trees
source secs mem gz cpu secs
PHP #3 45.39 921,556 428 45.38
PHP #7 15.05 948,676 760 53.85
PHP #4 17.63 918,536 779 54.47
PHP #2 61.41 748,808 423 61.39
PHP 61.61 748,832 451 61.60
PHP #5 32.52 805,504 1040 84.00
PHP #6 26.81 805,532 868 88.08
Perl #5 53.48 1,048,556 797 197.47
Perl 254.18 599,668 395 254.16
Perl #4 79.93 2,519,600 761 288.88
Perl #3 113.93 2,203,376 648 383.93
Perl

This is perl 5, version 36
subversion 0 (v5.36.0)
x86_64-linux-thread

PHP

PHP 8.2.1 (cli)
(built: Jan 13 2023 15:31:11) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.1,
with Zend OPcache v8.2.1,
Copyright (c) Zend Technologies