The Computer Language
22.05 Benchmarks Game

Fastest cpu secs Ruby versus PHP

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
Ruby #2 288,852 1455 1,010.75
Ruby 285,268 384 1,748.13
n-body
source mem gz cpu
PHP #3 12,372 1082 66.39
Ruby #3 285,504 1163 219.69
Ruby #2 285,552 1137 224.66
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
Ruby #4 287,424 326 113.59
Ruby 286,944 292 142.22
Ruby #5 288,548 758 216.98
mandelbrot
source mem gz cpu
PHP 12,664 449 86.95
PHP #3 140,544 875 92.75
Ruby #5 324,320 970 655.37
Ruby #4 409,304 857 857.98
Ruby #2 361,904 880 1,069.66
Ruby #3 285,212 307 1,470.34
Ruby #7   Failed  
Ruby #6   Failed  
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
PHP #2 14,172 545 1.46
Ruby #5 846,476 485 1.69
Ruby #2 613,348 658 2.74
Ruby 451,736 518 17.65
PHP 14,912 750 329.76
regex-redux
source mem gz cpu
PHP 178,712 816 3.66
Ruby #3 649,832 724 23.22
Ruby #2 684,764 437 23.23
Ruby #9 678,228 321 25.87
fasta
source mem gz cpu
PHP #3 12,448 1062 20.99
Ruby #6 340,624 1069 27.24
PHP #2 12,696 1050 28.67
Ruby #3 337,560 1002 50.87
Ruby #4 541,176 860 97.62
Ruby #5 286,228 995 98.69
Ruby #2 480,812 743 153.89
k-nucleotide
source mem gz cpu
PHP #4 257,260 1079 69.91
Ruby #2 455,288 420 243.58
Ruby #7 657,660 785 271.49
Ruby 408,036 576 281.84
Ruby #3 461,428 540 282.00
reverse-complement
source mem gz cpu
PHP 1,487,780 318 9.64
PHP #3 528,172 446 11.26
PHP #2 1,784,488 281 11.31
Ruby #5 1,874,980 295 11.49
Ruby #3 2,272,876 482 19.15
Ruby #2 774,468 264 19.40
Ruby #4 2,273,936 601 22.60
Ruby 2,273,352 514 32.89
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
Ruby #4 667,224 364 68.23
Ruby 667,228 376 71.73
Ruby #3 896,992 400 72.06
Ruby #2 667,172 378 72.24
Ruby #5 671,376 1008 75.52
PHP #5 803,212 1040 85.70
PHP #6 802,924 868 90.44
Ruby

ruby 3.1.2p20
(2022-04-12
revision 4491bb740a)
[x86_64-linux] --yjit

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