1 : Are the Ruby programs faster? At a glance.

Each chart bar shows, for one unidentified benchmark, how much the fastest Ruby program used compared to the fastest C++ g++ program.

(Memory use is only compared for tasks that require memory to be allocated.)


These are not the only compilers and interpreters. These are not the only programs that could be written. These are not the only tasks that could be solved. These are just 10 tiny examples.

 2 : Are the Ruby programs faster? Approximately.

Each table row shows, for one named benchmark, how much the fastest Ruby program used compared to the fastest C++ g++ program.

(Memory use is only compared for tasks that require memory to be allocated.)

 Ruby used what fraction? used how many times more? 
Benchmark Time Memory Code
 k-nucleotide±
 pidigits 1/3
 regex-dna±1/2
 reverse-complement11×1/21/9
 binary-trees19×±1/2
 fasta56× ±
 spectral-norm77× 1/3
 fasta-redux88× 1/2
 fannkuch-redux122× 1/3
 n-body152× ±
 mandelbrot163× 1/3
 Ruby used what fraction? used how many times more? 
Time-used  |-  |---  25% median  75%  ---|  -|
(Elapsed secs)56×105×163×163×

± read the measurements and then read the program source code.

 3 : Are the Ruby programs faster? Measurements.

These are not the only tasks that could be solved. These are just 10 tiny examples. These are not the only compilers and interpreters. These are not the only programs that could be written.

For each named benchmark, measurements of the fastest Ruby program are shown for comparison against measurements of the fastest C++ g++ program.

Program Source Code CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
 k-nucleotide 
Ruby51.9752.02357,432996  0% 1% 1% 100%
C++ g++24.0324.04138,9601252  1% 1% 0% 100%
 pidigits 
Ruby11.2711.2973,448240  0% 1% 1% 100%
C++ g++2.682.681,452682  0% 1% 4% 100%
 regex-dna 
Ruby29.8329.84143,640442  0% 1% 1% 100%
C++ g++5.335.34170,488695  0% 0% 1% 100%
 reverse-complement 
Ruby11.0411.05129,852255  0% 1% 1% 100%
C++ g++0.980.99245,6922275  3% 1% 0% 99%
 binary-trees 
Ruby212.24212.32135,148402  0% 1% 1% 100%
C++ g++10.9210.94148,508892  1% 1% 0% 100%
 fasta 
Ruby234.24234.705,380987  1% 1% 1% 100%
C++ g++4.224.228721286  1% 1% 0% 100%
 spectral-norm 
Ruby607.99608.156,016326  0% 1% 1% 100%
C++ g++7.927.939241044  0% 1% 1% 100%
 fasta-redux 
Ruby188.87189.80199,432772  0% 1% 1% 100%
C++ g++2.162.176201474  0% 2% 0% 100%
 fannkuch-redux 
Ruby3,316.173,317.055,348384  0% 1% 1% 100%
C++ g++27.2227.232841150  0% 1% 1% 100%
 n-body 
Ruby143.56143.605,4561137  0% 1% 0% 100%
C++ g++0.940.953321544  2% 0% 2% 100%
 mandelbrot 
Ruby242.02242.095,368307  1% 0% 0% 100%
C++ g++1.481.492,7721017  0% 2% 1% 99%

 4 : Are there other Ruby programs for these benchmarks?

Remember - those are just the fastest Ruby and C++ g++ programs measured on this OS/machine. Check if there are other implementations of these benchmark programs for Ruby.

Maybe one of those other Ruby programs is fastest on a different OS/machine.

 5 : Are there other faster programs for these benchmarks?

Remember - those are just the fastest Ruby and C++ g++ programs measured on this OS/machine. Check if there are faster implementations of these benchmark programs for other programming languages.

Maybe one of those other programs is fastest on a different OS/machine.

 Ruby : the new Ruby 

online book Programming Ruby: The Pragmatic Programmers Guide

ruby 2.1.5p273 (2014-11-13 revision 48405) [i686-linux]

Home Page: Ruby is…

Download: Ruby 2.1.0 is released

Revised BSD license

  Home   Conclusions   License   Play