The Computer Language
Benchmarks Game

Ruby versus PHP fastest programs

Always look at the source code.

These are only the fastest programs. Look at the other programs. They may seem more-like a fair comparison to you.

binary-trees
source secs mem gz busy cpu load
Ruby 44.61 531,600 1096 125.16 67% 72% 60% 81%
PHP 50.59 1,584,444 751 182.39 87% 86% 99% 90%
fasta
source secs mem gz busy cpu load
Ruby 51.74 123,240 1069 55.08 43% 44% 2% 17%
PHP 53.82 8,056 1062 54.91 1% 0% 100% 1%
n-body
source secs mem gz busy cpu load
Ruby 374.51 25,668 1137 387.63 67% 20% 2% 14%
PHP 310.34 8,040 1082 315.33 65% 16% 5% 16%
reverse-complement
source secs mem gz busy cpu load
Ruby 20.99 1,611,616 295 27.84 98% 7% 18% 9%
PHP 14.40 531,492 438 22.70 58% 30% 22% 48%
fannkuch-redux
source secs mem gz busy cpu load
Ruby 303.19 26,680 1444 1,169.40 100% 91% 98% 97%
PHP 206.72 22,548 1160 821.27 99% 99% 99% 100%
pidigits
source secs mem gz busy cpu load
Ruby 3.23 380,036 485 4.90 12% 50% 52% 37%
PHP 2.17 9,272 399 2.20 1% 100% 0% 0%
k-nucleotide
source secs mem gz busy cpu load
Ruby 103.71 400,128 859 377.05 95% 85% 95% 89%
PHP 41.23 168,632 1079 132.54 66% 85% 76% 93%
mandelbrot
source secs mem gz busy cpu load
Ruby 335.33 66,188 931 1,339.92 100% 100% 100% 100%
PHP 105.89 125,020 875 423.04 100% 100% 100% 100%
spectral-norm
source secs mem gz busy cpu load
Ruby 150.32 26,188 839 585.35 97% 97% 97% 97%
PHP 33.49 24,336 1152 132.61 99% 99% 99% 99%
regex-redux
source secs mem gz busy cpu load
Ruby 15.97 277,888 726 33.81 41% 76% 59% 36%
PHP 2.87 156,560 816 5.50 45% 34% 35% 78%
Ruby

ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
--jit

PHP

PHP 7.4.0 (cli) (built: Nov 28 2019 10:04:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies