The Computer Language
24.04 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 188.01 19,392 447 188.00
PHP #3 54.65 19,392 1166 217.72
PHP #4 55.26 19,520 1168 219.72
PHP 225.18 19,392 488 225.17
Perl #3 1,253.65 19,656 433 1,253.60
Perl #2 428.72 19,656 577 1,710.91
Perl 1,719.04 19,656 463 1,718.97
n-body
source secs mem gz cpu secs
PHP #3 66.45 19,396 1088 66.43
Perl #2 433.35 19,640 1431 433.33
spectral-norm
source secs mem gz cpu secs
PHP 6.85 19,396 1157 27.12
PHP #2 56.73 19,396 403 56.73
PHP #3 16.19 19,396 1214 63.39
Perl #4 23.84 19,644 562 93.18
Perl #5 97.85 19,640 346 97.84
Perl 106.13 19,644 340 106.10
Perl #2 488.38 19,644 350 488.35
Perl #3 122.80 19,640 857 488.65
mandelbrot
source secs mem gz cpu secs
PHP 86.84 19,396 452 86.84
PHP #3 23.33 48,384 881 92.86
Perl 569.19 76,928 592 2,273.81
pidigits
source secs mem gz cpu secs
PHP #5 1.02 19,396 405 1.02
PHP #4 1.04 19,396 396 1.04
PHP #3 1.05 19,396 510 1.04
PHP #2 1.47 19,396 552 1.46
Perl 11.68 19,380 471 11.66
PHP 330.35 19,396 756 330.33
Perl #2   Failed  
Perl #4   Failed  
regex-redux
source secs mem gz cpu secs
PHP 1.87 194,876 822 3.72
Perl 22.47 205,652 471 22.46
Perl #2 17.23 205,436 717 29.80
Perl #4 10.48 157,300 823 30.98
Perl #3 10.69 409,956 854 31.50
Perl #5   Bad Output  
fasta
source secs mem gz cpu secs
PHP #3 21.34 19,396 1065 21.33
PHP #2 28.90 19,396 1054 28.90
Perl 62.98 55,296 875 62.98
Perl #4 133.86 19,656 969 133.60
Perl #2 182.59 19,656 926 182.43
k-nucleotide
source secs mem gz cpu secs
PHP #4 20.89 260,560 1084 69.85
Perl #2 121.96 659,584 365 120.07
Perl 38.23 1,247,428 659 131.70
Perl #4 41.87 1,070,080 483 136.26
Perl #3 52.15 1,147,904 520 171.73
reverse-complement
source secs mem gz cpu secs
Perl #4 5.65 998,596 268 5.65
Perl #3 6.55 1,495,204 295 6.55
PHP 9.76 1,489,428 323 9.76
PHP #2 11.67 1,787,276 288 11.67
PHP #3 7.59 536,536 452 11.93
binary-trees
source secs mem gz cpu secs
PHP #3 45.78 921,600 434 45.78
PHP #7 15.25 948,480 767 54.73
PHP #4 18.02 918,400 786 55.68
PHP 62.31 748,808 457 62.30
PHP #2 62.55 748,812 429 62.54
PHP #5 32.58 805,504 1048 83.64
PHP #6 26.90 805,396 877 88.00
Perl #6 38.93 760,064 800 143.68
Perl #5 50.13 1,048,576 805 182.28
Perl 248.15 599,680 401 248.14
Perl #4 79.07 2,519,560 769 275.66
Perl #3 107.10 2,200,560 655 361.91
Perl

This is perl 5, version 38
subversion 2 (v5.38.2)
x86_64-linux-thread-multi

PHP

PHP 8.3.3 (cli)
(built: Mar 3 2024 08:47:21) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.3,
with Zend OPcache v8.3.3,
Copyright (c) Zend Technologies