The Computer Language
22.05 Benchmarks Game

Fastest cpu secs Ruby versus Python 3

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
Ruby #2 288,852 1455 1,010.75
Python 3 #6 7,432 385 1,279.15
Python 3 #4 45,420 950 1,336.72
Ruby 285,268 384 1,748.13
n-body
source mem gz cpu
Ruby #3 285,504 1163 219.69
Ruby #2 285,552 1137 224.66
Python 3 7,756 1196 575.02
Python 3 #2 8,244 1242 592.71
spectral-norm
source mem gz cpu
Ruby #4 287,424 326 113.59
Ruby 286,944 292 142.22
Ruby #5 288,548 758 216.98
Python 3 #6 9,332 328 436.79
Python 3 #8 48,336 407 472.82
Python 3 #7 48,400 417 494.32
mandelbrot
source mem gz cpu
Ruby #5 324,320 970 655.37
Python 3 #7 46,192 688 706.10
Ruby #4 409,304 857 857.98
Ruby #2 361,904 880 1,069.66
Ruby #3 285,212 307 1,470.34
Python 3 #5   Failed  
Ruby #7   Failed  
Ruby #6   Failed  
Python 3 #2   Timed Out  
pidigits
source mem gz cpu
Python 3 #3 11,968 567 1.13
Ruby #5 846,476 485 1.69
Ruby #2 613,348 658 2.74
Python 3 #4 8,668 342 4.06
Ruby 451,736 518 17.65
Python 3 #2   Bad Output  
regex-redux
source mem gz cpu
Python 3 #2 111,680 1403 2.66
Python 3 458,264 512 17.86
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
Ruby #6 340,624 1069 27.24
Ruby #3 337,560 1002 50.87
Python 3 #2 8,184 1121 60.26
Python 3 #3 8,112 1003 60.50
Python 3 8,040 817 70.54
Python 3 #5 837,684 1947 71.74
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
Python 3 #3 252,668 1967 172.53
Python 3 351,092 607 240.16
Python 3 #8 473,988 655 242.16
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
Python 3 #2 1,786,488 434 9.38
Python 3 1,979,276 479 9.63
Python 3 #6 1,005,184 814 10.64
Ruby #5 1,874,980 295 11.49
Python 3 #4 4,001,684 335 12.31
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
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
Python 3 #2 270,872 338 148.09
Python 3 #5 273,284 660 172.44
Python 3 #4 456,220 472 176.37
Python 3 282,996 589 178.66
Python 3 #3 669,832 1238 230.73
Ruby

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

Python 3

Python 3.10.4