The Computer Language
25.02 Benchmarks Game

Ruby versus Perl

How the programs are written matters! Always look at the source code.

If the fastest programs are flagged * possible hand-written vector instructions or "unsafe" or naked ffi, does the host language matter? You might be more interested in the less optimised programs — more seconds, less gz source code.

fannkuch-redux      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Ruby #2 154.32 593.14 23,679 1462
Perl #3 1,275.15 1,274.31 7,512 433
Ruby 1,437.74 1,436.24 17,695 391
Perl #2 432.70 1,723.38 16,654 577
Perl 1,836.45 1,835.47 7,524 463
Ruby #8 2,060.21 2,058.52 17,691 418
n-body      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Ruby #3 166.67 166.61—166.69 18,346 1169
Ruby #2 172.30 172.28—172.34 18,043 1143
Ruby #8 320.00 318.33 18,350 1160
Perl #2 452.42 451.65 8,741 1431
Ruby #7 768.29 766.83 18,326 1139
spectral-norm      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Perl 96.09 99.70—107.03 10,101 340
Perl #5 96.18 100.00—106.61 10,162 346
Perl #4 24.85 100.86—104.46 14,885 562
Ruby #4 126.05 126.09—127.01 20,025 333
Ruby #8 175.57 175.87—176.32 19,132 294
Ruby #5 56.52 207.11—207.67 43,725 764
Perl #2 513.08 512.36 9,581 350
Perl #3 130.52 517.15 14,729 857
mandelbrot      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Ruby #5 143.13 566.14 118,436 978
Ruby #4 579.40 578.27 169,955 853
Ruby #2 167.51 660.80 126,730 887
Ruby #8 944.53 943.02 50,926 364
Ruby #3 1,741.44 1,739.76 50,524 313
Perl 494.54 1,973.84 114,569 592
Ruby #6   Timed Out  
Ruby #7   Timed Out  
fasta      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Ruby #6 34.17 34.26—34.71 119,271 1097
Ruby #3 43.78 43.86—44.10 119,243 1035
Perl 59.63 60.57—63.69 58,769 875
Ruby #2 82.88 83.00—83.22 143,434 747
Ruby #5 99.47 99.61—100.05 19,194 1000
Perl #4 117.88 118.80—121.19 8,438 969
Ruby #4 129.31 129.79—130.82 305,578 864
Ruby #8 188.42 188.50—189.24 17,822 700
Perl #2   Bad Output  
k-nucleotide      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Perl #2 112.16 112.36—124.48 678,937 365
Perl 35.15 128.21—141.29 1,286,410 659
Perl #4 38.15 136.37—149.89 1,101,009 483
Perl #3 51.38 179.70—188.04 1,180,799 520
Ruby #7 243.79 246.45—258.00 399,401 792
Ruby #2 262.22 262.46—263.81 179,548 426
Ruby #3 263.08 264.95—272.82 207,466 546
Ruby 87.55 317.80 478,077 583
Ruby #8 519.31 517.57 872,055 529
reverse-complement      
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Perl #4 5.80 5.77—5.87 1,026,572 268
Perl #3 6.84 6.87—7.18 1,535,848 295
Ruby #4 6.01 11.72—11.85 3,079,053 608
Ruby #5 13.63 13.44—14.87 1,647,829 301
Ruby #3 8.46 16.69—17.00 4,884,902 490
Ruby #2 19.54 19.56—20.02 519,827 272
Ruby 13.29 25.90—26.00 6,528,086 521
binary-trees      [ Contentious. Different approaches. ]
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Ruby #4 47.09 47.06—47.17 489,144 371
Ruby #2 48.03 48.39—49.02 487,801 385
Ruby 48.14 48.56—49.08 487,592 383
Ruby #3 49.67 50.26—50.90 523,936 407
Ruby #5 18.86 53.95—54.17 2,280,051 1016
Perl #6 39.22 147.06—153.67 782,742 800
Perl #5 50.17 187.41—199.93 1,078,489 805
Perl 258.70 260.68—271.58 617,132 401
Perl #4 77.36 278.64—288.66 2,587,648 769
Perl #3 110.03 369.87 2,260,713 655
pidigits      [ Contentious. Different libraries. ]
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Perl 13.47 13.51—13.66 16,441 471
Ruby 17.94 18.01—18.15 53,740 524
Perl #2   Empty  
Perl #4   Empty  
Ruby #2   Empty  
Ruby #5   Empty  
regex-redux      [ Contentious. Different libraries. ]
  elapsed Mean or 95% CI      
source secs cpu secs mem gz make
Perl 22.37 22.36—22.45 212,926 471
Ruby #2 23.42 23.49—23.62 221,233 444
Ruby #3 12.42 24.39—24.49 217,313 730
Perl #2 17.14 29.70—31.19 212,640 717
Ruby #9 30.77 30.80—30.93 221,237 340
Perl #3 10.40 31.11—32.64 529,801 857
Perl #5   Bad Output  
Perl #4   Bad Output  
Ruby

ruby 3.4.0dev
(2024-12-25
master f450108330)
+YJIT +PRISM [x86_64-linux]

Perl

This is perl 5, version 40
subversion 0 (v5.40.0)
x86_64-linux-thread-multi