The Computer Language
24.11 Benchmarks Game

Java versus PHP fastest performance

How the programs are written matters! 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
Java #3 39.96 44,308 1264 40.06
Java 10.85 44,612 1289 42.80
Java #2 45.77 42,552 520 45.83
Java #8 45.90 42,568 517 45.97
PHP #2 460.00 19,700 447 459.93
PHP #4 128.28 19,700 1168 512.34
PHP #3 129.55 19,700 1166 514.06
PHP 591.53 19,700 488 591.44
PHP #8 1,731.37 19,700 477 1,731.10
n-body
source secs mem gz cpu secs
Java #4 6.88 42,028 1495 6.91
Java #5 7.30 43,424 1435 7.36
Java #2 7.48 42,260 1430 7.52
Java #3 7.49 42,292 1436 7.52
Java #8 7.59 42,924 1322 7.64
Java 7.84 42,652 1437 7.88
PHP #3 204.18 19,768 1088 204.15
PHP #8 246.25 19,768 1245 246.21
spectral-norm
source secs mem gz cpu secs
Java #8 5.43 43,368 453 5.49
Java #3 1.57 44,160 762 5.93
Java #2 1.61 43,028 956 6.08
PHP 18.14 19,768 1157 72.35
PHP #2 132.92 19,768 403 132.89
PHP #8 136.62 19,768 357 136.59
PHP #3 35.75 19,768 1214 141.74
mandelbrot
source secs mem gz cpu secs
Java #2 4.08 82,216 802 16.06
Java #4 4.41 105,000 667 16.14
Java #6 4.19 82,232 808 16.42
Java 24.50 42,272 671 24.57
Java #3 6.96 82,972 910 27.54
Java #8 27.67 45,844 441 27.79
PHP 262.49 19,768 452 262.45
PHP #3 71.34 47,676 881 284.83
PHP #8 420.99 19,768 419 420.89
fasta
source secs mem gz cpu secs
Java #4 3.28 44,352 1528 3.40
Java #6 1.16 49,848 2549 3.71
Java #5 1.24 49,640 2478 4.13
Java #2 4.45 48,896 1259 4.60
Java #8 10.12 182,140 894 10.66
PHP #3 31.09 19,768 1065 31.08
PHP #2 47.15 19,768 1054 47.14
PHP #8 49.44 19,960 760 49.43
k-nucleotide
source secs mem gz cpu secs
Java 4.92 427,448 1821 15.77
Java #6 7.27 426,032 1614 25.17
Java #3 7.34 426,540 1642 25.47
Java #4 34.33 197,748 1887 34.67
Java #5 22.10 222,396 2225 48.14
PHP #8 79.41 629,652 571 79.39
Java #8 81.36 1,559,968 786 83.57
PHP #4 25.74 259,940 1290 90.19
reverse-complement
source secs mem gz cpu secs
Java #6 3.15 2,032,996 760 3.79
Java #5 4.72 1,097,732 1115 4.84
Java #4 5.65 1,891,656 656 5.77
Java #7 23.98 1,037,708 1654 6.26
PHP 10.22 1,488,780 323 10.22
PHP #2 12.21 1,786,608 288 12.20
PHP #3 8.13 536,024 452 12.47
Java #3   Bad Output  
binary-trees
source secs mem gz cpu secs
Java #4 4.41 1,821,244 846 5.14
Java #6 4.87 1,782,568 535 5.63
Java #3 4.85 1,769,500 546 5.65
Java #2 5.09 1,820,068 558 5.83
Java #8 6.57 1,767,108 596 7.29
Java #7 2.62 1,803,192 841 8.14
PHP #3 69.49 920,800 434 69.47
PHP #4 24.86 917,608 786 81.20
PHP #7 22.22 947,804 767 81.25
PHP 90.61 748,120 457 90.59
PHP #2 93.68 748,028 429 93.66
PHP #5 47.37 804,828 1048 125.31
PHP #6 38.24 804,884 877 130.14
PHP #8 146.78 749,804 590 146.75
pidigits
source secs mem gz cpu secs
* Java #3 0.80 41,900 770 0.83
PHP #5 0.97 19,768 405 0.97
PHP #3 0.99 19,768 510 0.99
PHP #4 0.99 19,768 396 0.99
* Java #2 1.29 45,768 944 1.37
PHP #2 1.49 19,768 552 1.49
Java 7.68 482,056 807 8.75
PHP 102.67 19,768 756 102.65
regex-redux
source secs mem gz cpu secs
Java #2 1.55 372,764 2201 3.16
PHP 1.87 194,684 822 3.70
Java 8.47 575,552 875 16.69
Java #6 5.60 1,237,440 746 17.12
Java #3 5.25 611,476 935 17.25
Java

java 23 2024-09-17
Java HotSpot(TM) 64-Bit Server VM
(build 23+37-2369,
mixed mode, sharing)

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